Platform: Code4rena
Start Date: 27/01/2022
Pot Size: $90,000 USDC
Total HM: 21
Participants: 33
Period: 7 days
Judge: Jack the Pug
Total Solo HM: 14
Id: 78
League: ETH
Rank: 33/33
Findings: 1
Award: $8.37
🌟 Selected for report: 0
🚀 Solo Findings: 0
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 are five examples of this issue in the codebase:
for (uint256 i = 0; i < tokens.length; i++) approvedTokens[tokens[i]] = value;
for (uint256 i = 0; i < LPs.length; i++) {
https://github.com/code-423n4/2022-01-behodler/blob/main/contracts/testing/MockToken.sol#L15
for (uint256 i = 0; i < sushiLPs.length; i++) {
https://github.com/code-423n4/2022-01-behodler/blob/main/contracts/DAO/LimboDAO.sol#L212
for (uint256 i = 0; i < uniLPs.length; i++) {
https://github.com/code-423n4/2022-01-behodler/blob/main/contracts/DAO/LimboDAO.sol#L217
for (uint256 i = 0; i < params.length; i++) {
Code inspection
Use ++i
rather than i++
in all places
#0 - gititGoro
2022-02-10T00:04:51Z
duplicate of issue 10