Use uint256 iterators in MerkleTree loops (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@heueristik

Description

@heueristik

🧐 Motivation

The current MerkleTree.sol contract contains two for loops, both of which use uint32 as an iterator when iterating from 0 to uint8 treeDepth. This is not optimal and uint256 should be used to minimize conversions.

📝 Details

Use uint256 for the iterators in MerkleTree.sol

for (uint32 i = 0; i < treeDepth; ++i) {
for (uint32 i = 0; i < treeDepth; i++) {

to save gas.

While on it, you can also change the for loops in the Heap.t.sol test.

for (uint32 i = 1; i < heap.length(); ++i) {