Closed code423n4 closed 2 years ago
WatchPug
Using ++i is more gas efficient than i++, especially in a loop.
++i
i++
We suggest using unchecked {++i} to even better gas performance.
unchecked {++i}
For example:
https://github.com/code-423n4/2021-11-streaming/blob/56d81204a00fc949d29ddd277169690318b36821/Streaming/src/LockeERC20.sol#L222-L225
while (j != 0) { len++; j /= 10; }
dupe of #263 (same optimization)
Handle
WatchPug
Vulnerability details
Using
++i
is more gas efficient thani++
, especially in a loop.We suggest using
unchecked {++i}
to even better gas performance.For example:
https://github.com/code-423n4/2021-11-streaming/blob/56d81204a00fc949d29ddd277169690318b36821/Streaming/src/LockeERC20.sol#L222-L225