I remember many years ago they were teaching us to create local variables outside of loops, e.g.:
SomeVariable* var;
for(int i; i<10; i++)
{
var = [someArray objectAtIndex:i];
(...)
}
I would assume that with modern compilers such optimization is done automatically, e.g. in Objective C the code below would be optimized to execute as fast as the code above:
for(int i; i<10; i++)
{
SomeVariable* var = [someArray objectAtIndex:i];
(...)
}
Am I right?
for-inloop is optimized to execute as fast.Eg: