'Expensive' expressions in loop limits (was: Implementation of D3DXSHScale)

Dan Kegel dank at kegel.com
Tue Jun 19 03:47:42 CDT 2012

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?

D3DXSHAdd() has the same code, which is where this came from, probably.

More information about the wine-devel mailing list