Optimize validateWeights #213
Labels
bug
Warden finding
duplicate
Another warden found this issue
G (Gas Optimization)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
pauliax
Vulnerability details
Impact
I assume function validateWeights is very gas-consuming as it iterates against all the tokens again and again and re-assigns dynamic arrays multiple times. I think a good improvement that you may consider would be to ask the _tokens array to be provided in descending order, then a validation would be much cheaper.
Recommended Mitigation Steps
An example solution:
The text was updated successfully, but these errors were encountered: