Cache length of array when looping #17
Labels
bug
Something isn't working
G (Gas Optimization)
invalid
This doesn't seem right
sponsor acknowledged
Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Handle
0x0x0x
Vulnerability details
Proof of Concept
Example:
Loading length of array costs gas. Therefore, the length should be cached, if the length of the array doesn't change inside the loop.
Recommended implementation:
By doing so the length is only loaded once rather than loading it as many times as iterations (Therefore, less gas is spent).
Occurences
The text was updated successfully, but these errors were encountered: