Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Is it good to give a function a struct of 4 chars or maybe it is

Author: Bruce Moreland

Date: 13:08:05 04/16/03

Go up one level in this thread


On April 16, 2003 at 05:34:02, Uri Blass wrote:

>better to give only part of the chars that are used in the function?
>
>The problem is that my makemove get a struct of 4 chars
>with details about the move(maybe it is better to use one integer and to get rid
>of the 4 chars but I decided that it is a big change that I do not like to do
>now).
>
>I call from makemove to functions that get part of the chars
>for example
>
>updateblackpiece(m.from,m.to);
>
>The question is if it is better to call only m and not the 2 varaibles
>m.to and m.from
>
>
>there is already a union that include these numbers so I assume
>that they they are in memory.
>
>I also plan to write a function that update some varaibles and
>I need only m.from,m.to,m.bits and I do not need m.promote and
>the question is if using m is better than using 3 of the
>4 varaibles.
>
>Another solution is to have a global structure of 4 chars for the move that
>the program consider and to update it every time that I make a move in the
>beginning of makemove so I do not need to give parameters to the functions
>that movei call.
>
>Note that my undomove does not get a move as a varaible and
>I start it by
>
>move_bytes m=hist_dat[hply-1].m.b;
>
>I update
>hist_dat[hply].m.b in my make move but it is clear that it is not
>a good idea to use this global array to get the numbers and maybe it is better
>to have m as global varaible so I can use it in every function.
>
>
>What is the best solution?
>
>I do not see difference in readibility if I give m to a function
>or give  2 chars to the same function and I want to know a clear rule what is
>faster not by try and error.
>
>Uri

You gotta test it.  You are probably sign-extending all over the place, which
used to be very nasty-bad, and still might be, but on the other hand, you have a
little less memory bandwidth.

If you are serious, you will try it both ways.  Be a man.

bruce




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.