The function getTotalWeight()
iterates through _gaugeList
and repeatedly accesses storage variables gauges[_gaugeList[i]].isActive
and gauges[_gaugeList[i]].weight
. This results in multiple expensive SLOAD operations, increasing gas consumption.
Each iteration of the loop fetches gauges[_gaugeList[i]].isActive
and gauges[_gaugeList[i]].weight
directly from storage.
Storage reads (SLOAD) are significantly more expensive than memory reads.
The repeated access to storage in a loop leads to unnecessary gas costs.
Excessive gas usage due to multiple redundant storage reads, leading to higher transaction costs.
Manual Review
Cache the storage variable into memory before the loop to minimize repeated SLOAD operations:
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.