Say we have a contract with a dynamic state array fooArray of uint256. At the same contract there is a function with the following loop:
for (uint256 i = 0; i < fooArray.length; ++i) {
// Some code here, that does not modify array in any way.
}
Does checking the loop condition require reading the length of the fooArray from the storage on each iteration or it is not considered as reading a value from the storage?
Should I preliminarily save length of the array to a local variable and use this variable as a loop condition to save gas?