Sfoglia il codice sorgente

Optimize `MerkleTree` for loops by using `uint256` iterators (#5415)

Co-authored-by: Ernesto García <ernestognw@gmail.com>
Michael 9 mesi fa
parent
commit
a99b31f990
1 ha cambiato i file con 2 aggiunte e 2 eliminazioni
  1. 2 2
      contracts/utils/structs/MerkleTree.sol

+ 2 - 2
contracts/utils/structs/MerkleTree.sol

@@ -88,7 +88,7 @@ library MerkleTree {
 
         // Build each root of zero-filled subtrees
         bytes32 currentZero = zero;
-        for (uint32 i = 0; i < treeDepth; ++i) {
+        for (uint256 i = 0; i < treeDepth; ++i) {
             Arrays.unsafeAccess(self._zeros, i).value = currentZero;
             currentZero = fnHash(currentZero, currentZero);
         }
@@ -143,7 +143,7 @@ library MerkleTree {
         // Rebuild branch from leaf to root
         uint256 currentIndex = index;
         bytes32 currentLevelHash = leaf;
-        for (uint32 i = 0; i < treeDepth; i++) {
+        for (uint256 i = 0; i < treeDepth; i++) {
             // Reaching the parent node, is currentLevelHash the left child?
             bool isLeft = currentIndex % 2 == 0;