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

use unchecked {++i;} for loops to save gas

Summary

use unchecked {++i;} for loops to save gas

Vulnerability Details

As the iterator is bound by the length of the array, the iterator would never overflow. So, the following can be done to save gas in for loops:

unchecked {
++i;
}

Impact

Saves gas on various iterations, as the compiler need not check for overflow on each increment operation of the iterator.

Tools Used

Manual review

Recommendations

As suggested, do the following in for loops:

unchecked {
++i;
}

Support

FAQs

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