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

++i/i++ SHOULD BE UNCHECKED{++i}/UNCHECKED{i++} WHEN IT IS NOT POSSIBLE FOR THEM TO OVERFLOW, AS IS THE CASE WHEN USED IN FOR- AND WHILE-LOOPS

Summary

[G-6] ++i/i++ SHOULD BE UNCHECKED{++i}/UNCHECKED{i++} WHEN IT IS NOT POSSIBLE FOR THEM TO OVERFLOW, AS IS THE CASE WHEN USED IN FOR- AND WHILE-LOOPS

In Solidity 0.8+, there’s a default overflow check on unsigned integers. It’s possible to uncheck this in for-loops and save some gas at each ,iteration, but at the cost of some code readability, as this uncheck cannot be made inline

file: /src/DSCEngine.sol
118 for (uint256 i = 0; i < tokenAddresses.length; i++) {

https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/main/src/DSCEngine.sol#L118

file: /src/DSCEngine.sol
353 for (uint256 i = 0; i < s_collateralTokens.length; i++) {

https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/main/src/DSCEngine.sol#L353

Support

FAQs

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