Platform: Code4rena
Start Date: 27/01/2022
Pot Size: $75,000 USDC
Total HM: 10
Participants: 26
Period: 7 days
Judge: pauliax
Total Solo HM: 5
Id: 81
League: ETH
Rank: 22/26
Findings: 1
Award: $23.04
🌟 Selected for report: 1
🚀 Solo Findings: 0
23.0433 USDC - $23.04
IllIllI
When the value of the post-loop increment/decrement is not stored or used in any calculations, the prefix increment/decrement operators (++i
/--i
) cost less gas PER LOOP than the postfix increment/decrement operators (i++
/i--
)
There is one example of this issue in the codebase:
for (uint256 i; i < currencies.length; i++) {
https://github.com/code-423n4/2022-01-notional/blob/main/contracts/TreasuryAction.sol#L157
Code inspection
Use ++i
rather than i++
in all places
#0 - jeffywu
2022-02-06T14:06:28Z
Many duplicates for this issue.
#1 - pauliax
2022-02-13T10:35:01Z
Well, technically a valid optimization, even though I am not a big fan of it.