Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: question about speed

Author: Robert Hyatt

Date: 20:23:48 04/19/03

Go up one level in this thread


On April 19, 2003 at 11:28:51, Uri Blass wrote:

>Note that in this post I use for doing the post more readable
>
>if (pawnmove||pawncapture) instead of
>if  ((m.bits&16)||piece(m.to)==PAWN)

The latter is generaly better.  The former will often turn into _two_
tests and branches, although a compiler might optimize it into one if it
is very good...

ie it could use (if pawnmove | pawncapture) which ors the two together
and then tests them with one compare/branch.



>
>
>
>I have in movei the following code
>
>if (pawnmove||pawncapture)
>if (side==LIGHT)
>undomovewhitepawndata(m);
>else
>undomoveblackpawndata(m);
>
>
>The point is that
>undomovewhitepawndata(m) and undomovewhitepawndata(m) has a common part and I
>also have
>if (pawnmove) or if (pawncapture) in these functions.
>
>You can say that speed is not important becauase I can put the pawndata in the
>hash tables but I am interested to know from speed point of view if there is a
>better way because it can help me later in other decisions.
>
>I do not like to check the condition pawnmove twice and this is exactly what I
>do in the structure that I described.
>
>I also think that it may be better to use one function undomovepawndata when
>that function can call both undomovewhitepawn data and undomoveblackpawndata
>based on the value of side so I can do the code smaller by not writing the
>common part twice.
>
>Uri

The idea is to "test".  What is faster for me is not necessarily faster for
everyone.  If you are running tight on registers, it might be faster to do it
one way than another.  And vice-versa if you are not.




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.