|
@@ -135,7 +135,7 @@ library MerkleProof {
|
|
|
// At each step, we compute the next hash using two values:
|
|
|
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
|
|
|
// get the next hash.
|
|
|
- // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
|
|
|
+ // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
|
|
|
// `proof` array.
|
|
|
for (uint256 i = 0; i < totalHashes; i++) {
|
|
|
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
|
|
@@ -146,7 +146,9 @@ library MerkleProof {
|
|
|
}
|
|
|
|
|
|
if (totalHashes > 0) {
|
|
|
- return hashes[totalHashes - 1];
|
|
|
+ unchecked {
|
|
|
+ return hashes[totalHashes - 1];
|
|
|
+ }
|
|
|
} else if (leavesLen > 0) {
|
|
|
return leaves[0];
|
|
|
} else {
|
|
@@ -185,7 +187,7 @@ library MerkleProof {
|
|
|
// At each step, we compute the next hash using two values:
|
|
|
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
|
|
|
// get the next hash.
|
|
|
- // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
|
|
|
+ // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
|
|
|
// `proof` array.
|
|
|
for (uint256 i = 0; i < totalHashes; i++) {
|
|
|
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
|
|
@@ -196,7 +198,9 @@ library MerkleProof {
|
|
|
}
|
|
|
|
|
|
if (totalHashes > 0) {
|
|
|
- return hashes[totalHashes - 1];
|
|
|
+ unchecked {
|
|
|
+ return hashes[totalHashes - 1];
|
|
|
+ }
|
|
|
} else if (leavesLen > 0) {
|
|
|
return leaves[0];
|
|
|
} else {
|