Skip to content

Commit

Permalink
slither: use cached array length
Browse files Browse the repository at this point in the history
  • Loading branch information
adu-web3 committed Jul 5, 2024
1 parent 92a149c commit a4f8435
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/Bootstrap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ contract Bootstrap is
*/
function consensusPublicKeyInUse(bytes32 newKey) public view returns (bool) {
require(newKey != bytes32(0), "Consensus public key cannot be zero");
for (uint256 i = 0; i < registeredOperators.length; i++) {
uint256 arrayLength = registeredOperators.length;
for (uint256 i = 0; i < arrayLength; i++) {
address ethAddress = registeredOperators[i];
string memory exoAddress = ethToExocoreAddress[ethAddress];
if (operators[exoAddress].consensusPublicKey == newKey) {
Expand Down Expand Up @@ -274,7 +275,8 @@ contract Bootstrap is
* safely used for a new operator.
*/
function nameInUse(string memory newName) public view returns (bool) {
for (uint256 i = 0; i < registeredOperators.length; i++) {
uint256 arrayLength = registeredOperators.length;
for (uint256 i = 0; i < arrayLength; i++) {
address ethAddress = registeredOperators[i];
string memory exoAddress = ethToExocoreAddress[ethAddress];
if (keccak256(abi.encodePacked(operators[exoAddress].name)) == keccak256(abi.encodePacked(newName))) {
Expand Down

0 comments on commit a4f8435

Please sign in to comment.