ILE C/C++ Programmer's Guide

Reducing Indirect Access through Pointers

You can improve performance by reducing indirect access through pointers. Each level of indirection adds some overhead:

 for ( i = 0; i < n; i++ )
 {
    x->y->z[i] = i;
 }

Performance in the above example improves if it is rewritten as:

temp = x->y;
for ( i = 0; i < n; i++ )
{
  temp->z[i] = i;
}


[ Top of Page | Previous Page | Next Page | Table of Contents ]