The function _distributeToGauges creates a fixed-size array gaugeWeights with the length of _gaugeList, which leads to unnecessary memory allocation when only a subset of the list is active. This results in wasteful storage usage and increased gas costs.
In _distributeToGauges, the following line initializes a fixed-size array:
This means that memory is allocated for all elements in _gaugeList, even though only active gauges are used. If _gaugeList is large but has only a few active gauges, this results in unnecessary computational overhead.
Increased gas costs due to wasteful memory allocation.
Unoptimized resource usage, especially when _gaugeList contains many inactive gauges.
Manual code review
Use dynamic memory allocation by storing active gauge weights in a dynamically growing array, such as Array.push().
Alternatively, store weights in a mapping instead of an array, avoiding unnecessary memory allocation.
By using push(), the function only allocates memory for active gauges, optimizing gas usage and execution efficiency.
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.