Closed code423n4 closed 1 year ago
Context:
Description:
This can save 30-40 gas per loop iteration.
Recommendation:
Change:
for (uint256 i = 0; i < orders.length; ++i) { // Do the thing }
To:
for (uint256 i = 0; i < orders.length;) { // Do the thing unchecked { ++i; } }
Some gas can be saved by using an unchecked {} block if an overflow/underflow isn't possible because of a previous require() or if-statement.
Place the arithmetic operations in an unchecked block.
Recommendation: If a reference type function parameter is read-only, it is recommended to use calldata instead of memory because this provides significant gas savings.
Picodes marked the issue as grade-c
Report
Gas Optimizations
[G-01]: The increment in for loop post condition can be made unchecked
Context:
Description:
This can save 30-40 gas per loop iteration.
Recommendation:
Change:
To:
[G-02]: Unchecked arithmetic
Context:
Description:
Some gas can be saved by using an unchecked {} block if an overflow/underflow isn't possible because of a previous require() or if-statement.
Recommendation:
Place the arithmetic operations in an unchecked block.
[G-03]: Use calldata instead of memory
Context:
Recommendation: If a reference type function parameter is read-only, it is recommended to use calldata instead of memory because this provides significant gas savings.