There is some abstract loop that loops through array, and processes every single element without dependency of it's place in array. Element value is checked against conditions many times.
Adding int value = arr[i] will help reading the code, and theoretically, will take sizeof(int) memory away.
Will it boost performance? Or will compiler optimize it?
I know, early-optimization is very very bad, that is theoretical question.
int arr[10];
...
for (int i = 0; i < 10; i++)
{
if (arr[i] > 2)
{
if (arr[i] < 100)
{
do_smth1(arr[i]);
}
else if (arr[i] > 500 && arr[i] < 1000)
{
do_smth2(arr[i]);
}
else
{
do_smth3(arr[i]);
}
}
else
{
do_smth4(arr[i]);
}
}