Author: Tom Likens
Date: 07:03:37 01/09/04
Go up one level in this thread
On January 09, 2004 at 06:46:00, Tord Romstad wrote:
>By reading this forum, I've understood that "if" statements are considered
>evil and that it is often a good idea to remove them if it is possible. Suppose
>that I have code which looks like this:
>
>if(x) y += 20;
>
>Would it then be advantageous to rewrite the code like this?
>
>y += (!(!x))*20;
>
>In my evaluation function, I have a lot of conditionals which could be avoided
>by
>using tricks similar to the one above, but before doing it I would like to make
>sure it is really a good idea. After all, the first form above is much more
>readable.
>
>Tord
Hello Tord,
I suspect that your second construct will contain at least one branch. You
might want to
verify that (either yea or nay) by compiling it with the -S switch. You could
then look
at the actual assembly to see what the compiler is doing.
regards,
--tom
P.S. I think it *must* have gotten very chilly somewhere if Tord Romstad is
considering low-
level optimizations!! :-)
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.