On 06/19/2012 10:47 AM, Dan Kegel wrote:
> Nozomi wrote:
> +    for (i = 0; i < order * order; i++)
> 
> I might have written
>      int n = order * order;
>      for (i=0; i < n; i++)
> to avoid repeating the multiplication every time around the loop,
> even though multiplication is cheap nowadays, and -O1 will optimize
> it out anyway.   Staying in the habit of avoiding 'expensive'
> operations in loop limits might still be a good idea, since the
> optimizer can't always save you.
> 
> Or is that considered ugly these days?
Of course as always a definitive "It depends". The safe approach is to
*first* optimize for the human reader; the compilers this days are
better at optimizing than the average programmer.

bye
        michael


Reply via email to