Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Re: Map coordinate cleanups.
Home

[Freeciv-Dev] Re: Map coordinate cleanups.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Kevin Brown <kevin@xxxxxxxxxxxxxx>
Cc: Vasco Alexandre Da Silva Costa <vasc@xxxxxxxxxxxxxx>, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Map coordinate cleanups.
From: Tony Stuckey <stuckey@xxxxxxxxxxxxxxxxx>
Date: Fri, 17 Aug 2001 11:02:40 -0500

On Fri, Aug 17, 2001 at 08:43:17AM -0700, Kevin Brown wrote:
> The real question, of course, is just how much of a difference does it
> really make?  It's worth putting something into a macro instead of a
> function if it gives you an order of magnitude speedup for a
> significant (30% or so) part of the execution of the program, but
> anything less than that isn't even worth the hassle unless the use of
> a macro instead of a function gives you other benefits (readability,
> ease of comprehension, flexibility, etc.).  And keep in mind that the
> macro has to be that much faster than an *inline* function, which
> means that the optimizer has to make that much of a difference.  I'll
> concede that this is possible, but I have trouble imagining that it
> would happen often enough to make use of macros the preferred method
> of improving performance.

        Theoretically, there is no difference between a macro and an inline
function.  Neither needs to push arguments into stack space, jump
elsewhere, etc.
        When the code for the non-inline function is dominated by the call
overhead (as many one or two-line functions will be!) then a macro probably
makes serious performance gains possible.
        I wouldn't be surprised if a lot of the is_real_tile(), etc style
code that has been discussed recently was turned into 3 or fewer machine
instructions on modern hardware.  (68K, i386, PPC, Sparc, etc).

        Compile it and see.
-- 
Anthony J. Stuckey                              stuckey@xxxxxxxxxxxxxxxxx
"And they said work hard, and die suddenly, because it's fun."
        -Robyn Hitchcock.


[Prev in Thread] Current Thread [Next in Thread]