Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Question for compiler gurus

Author: Reinhard Scharnagl

Date: 08:14:43 10/01/04

Go up one level in this thread


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.



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.