Prefix increments are cheaper than postfix increments #7
Labels
bug
Something isn't working
duplicate
This issue or pull request already exists
G (Gas Optimization)
Handle
robee
Vulnerability details
Prefix increments are cheaper than postfix increments.
Further more, using unchecked {++x} is even more gas efficient, and the gas saving accumulates every iteration and can make a real change
There is no risk of overflow caused by increamenting the iteration index in for loops (the
++i
infor (uint256 i = 0; i < numIterations; ++i)
).But increments perform overflow checks that are not necessary in this case.
These functions use not using prefix increments (
++x
) or not using the unchecked keyword:The text was updated successfully, but these errors were encountered: