Use uint256
iterators in MerkleTree
loops (original) (raw)
Navigation Menu
- GitHub Copilot Write better code with AI
- GitHub Models New Manage and compare prompts
- GitHub Advanced Security Find and fix vulnerabilities
- Actions Automate any workflow
- Codespaces Instant dev environments
- Issues Plan and track work
- Code Review Manage code changes
- Discussions Collaborate outside of code
- Code Search Find more, search less
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
🧐 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) { |
---|