15,000 USDC
View results
Submission Details
Severity: gas
Valid

The increment `++i/i++` in `for-loop`/`while-loop` post condition can be made `unchecked{++i}/unchecked{i++}`

Summary

Vulnerability Details

The unchecked keyword is new in solidity version 0.8.0, so this only applies to that version or higher, which these instances are.
Gas savings: roughly speaking this can save 30-40 gas per loop iteration. For lengthy loops, this can be significant!

More detail see this.

There are 2 instances of this issue:

  • i ++ should be used unchecked{++i}/unchecked{i++}.

  • i ++ should be used unchecked{++i}/unchecked{i++}.

Impact

Tools Used

Recommendations

Using unchecked{++i}/unchecked{i++} replace ++i/i++ in loop.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.