An array’s length should be cached to save gas in for-loops
Reading array length at each iteration of the loop takes 6 gas (3 for mload and 3 to place memory_offset) in the stack.
Caching the array length in the stack saves around 3 gas per iteration.
Instances:
MyStrategy.sol:300: for (uint256 i = 0; i < _claims.length; i++) {
MyStrategy.sol:317: for (uint256 i = 0; i < _claims.length; i++) {
Remediation:
Here, I suggest storing the array’s length in a variable before the for-loop, and use it instead.
An array’s length should be cached to save gas in for-loops
Reading array length at each iteration of the loop takes 6 gas (3 for mload and 3 to place memory_offset) in the stack. Caching the array length in the stack saves around 3 gas per iteration.
Instances:
Remediation:
Here, I suggest storing the array’s length in a variable before the for-loop, and use it instead.