15,000 USDC
View results
Submission Details
Severity: gas

State variable read in a loop

Summary

[G-22] State variable read in a loop

State variable reads and writes are more expensive than local variable reads and writes. Therefore, it is recommended to replace state variable reads and writes within loops with local variable reads and writes.

file: /src/DSCEngine.sol
119 s_priceFeeds[tokenAddresses[i]] = priceFeedAddresses[i];

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

file: /src/DSCEngine.sol
120 s_collateralTokens.push(tokenAddresses[i]);

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

Support

FAQs

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