Accessing storage variables within a loop is gas-inefficient because each access involves a read operation from storage. Reading from storage repeatedly can significantly increase the gas costs compared to reading from memory. To improve efficiency, storage variables should be cached in a local variable when used multiple times within a loop.
Excessive storage reads can lead to higher gas costs, especially in loops, and can make the contract less efficient.
Manual review
Cache the storage variable in a local memory variable before entering the loop. This approach reduces the number of storage reads and lowers gas costs.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.