Author: Dan Honeycutt
Date: 08:48:25 10/01/04
Go up one level in this thread
On October 01, 2004 at 11:14:43, Reinhard Scharnagl wrote: >On October 01, 2004 at 10:58:43, Dan Honeycutt wrote: > >>If I have an inline function, ie: >> >>_inline int Distance(int square1, int square2) >> >>which is going to return the max rank/file difference but is not going to alter >>the arguements, would I be better off passing the arguements by reference, ie: >> >>_inline int Distance(int & square1, int & square2) >> >>so as to save having to make a copy of the arguements. Or would the compiler >>figure that out on it's own since the function is inline? I'm using MS VC 6. >> > >Well I am not a guru, but taking an int not by value does only make sense if >the original data should be changed. Copying an address could never be faster >than copying an int. And a good compiler will work within inline parts with the >original variables not with copies. But may be I have not seen your problem yet. > >Reinhard. Hi Reinhard: Let me clarify a bit. The body of Distance() looks like: return Max(RankDiff(square1, square2), FileDiff(square1, square2)); The calling function looks like: square1 = ... square2 = ... d = Distance(square1, square2); When the function is inlined I want: square1 = ... square2 = ... d = Max(RankDiff(square1, square2), FileDiff(square1, square2)); But do I get square1 = ... square2 = ... copy1 = square1; copy2 = square2; d = Max(RankDiff(copy1, copy2), FileDiff(copy1, copy2)); And if i do get the latter form, would a pass by reference be better? Thanks Dan H
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.