When array length isn't cached, the Solidity compiler repeatedly reads it in every loop iteration. For storage arrays, this means an added sload operation costing 100 extra gas for each subsequent iteration. For memory arrays, it's an additional mload operation costing 3 extra gas post the first iteration.
Context
Vault::collaterals() LiquidationRouter::collaterals() VaultFactoryHelper::getVaultTvl() VaultFactoryHelper::getRedeemableVaults()
Description
When array length isn't cached, the Solidity compiler repeatedly reads it in every loop iteration. For storage arrays, this means an added sload operation costing 100 extra gas for each subsequent iteration. For memory arrays, it's an additional mload operation costing 3 extra gas post the first iteration.