Loop Unrolling

Listing: Loop Unrolling, Before Optimization

const int MAX = 100;

void func(int* vec)

{
   int i;
   for (i = 0; i < MAX; ++i)
    {
       otherfunc(vec[i]);
    }
}
Listing: Loop Unrolling, After Optimization

const int MAX = 100;
void func_optimized(int* vec)
{
    int i;
    for (i = 0; i < MAX;)
    {
       otherfunc(vec[i]);
       ++i;
       otherfunc(vec[i]);
       ++i;
    }
}