Author: Russell Reagan
Date: 15:58:41 01/01/03
Go up one level in this thread
On January 01, 2003 at 18:02:35, Andreas Guettinger wrote:
>Why is
>
>int x = R[i];
>if (x == 3 || x == 7) {;}
>
>faster than
>
>if((R[i]==3)||(R[i]==7)) {;}
>
>Isn't the creation and assignment of x a waste of time?
To get a value of the array element R[i], you have to calculate what spot in
memory that is. It's the same as *(R + i), so there is an extra addition in
there. Maybe that is what he was talking about. Of course, any decent compiler
should be able to optimize this kind of stuff away so it shouldn't matter. In
fact, it shouldn't matter even with no optimization.
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.