Save gas by caching array length used in for loops #7
Labels
bug
Something isn't working
G (Gas Optimization)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
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: