Author: Jaime Benito de Valle Ruiz
Date: 05:24:57 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 ------------------------------------------------------------------- If you call two char arguments the compiler will probably read one char, put in the stack, get a second char, and put it in the stack again. If you send the whole "m" -and you make sure is 4 bytes long (very important)- the compiler will just read an integer, which is faster, and will put it in the stack all in one go, optimizing the speed. the function will probably retrieve those chars exactly the same way, no matter how you send them, so I'd send the whole int32 long structure if I were you, because it is more efficient than sending m.a, for example. -------------------------------------------------------------------- > > >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. ----------------------------------------------------------------- Same here: keep m four bytes long, and send m all the time. ----------------------------------------------------------------- > >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
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.