Caching the array length outside a loop in a variable saves reading it on each
iteration, as long as the array's length is not changed during the loop.
Therefore, the following loops could be refactored:
arbitrum-lpt-bridge:
- L1/gateway/L1Migrator -> Line 472
- L2/gateway/L2Migrator -> Line 197
Recommended Mitigation Steps
Use the following pattern for refactoring:
uint256 len = array.length;
for (uint256 i; i < len; i++) {
// ...
}
Handle
byterocket
Vulnerability details
Impact
Caching the array length outside a loop in a variable saves reading it on each iteration, as long as the array's length is not changed during the loop.
Therefore, the following loops could be refactored:
Recommended Mitigation Steps
Use the following pattern for refactoring: