Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2001:
[Freeciv-Dev] Re: [PATCH] is_real_tile().
Home

[Freeciv-Dev] Re: [PATCH] is_real_tile().

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gaute B Strokkenes <gs234@xxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [PATCH] is_real_tile().
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 28 Sep 2001 10:10:26 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Fri, Sep 28, 2001 at 03:14:40AM +0200, Gaute B Strokkenes wrote:
> On Fri, 28 Sep 2001, gs234@xxxxxxxxx wrote:
> > 
> > This patch contains a macroised version of is_real_tile(), as
> > discussed previously.  I do not have the means to profile this
> > extensively ATM, but recent findings show that the run-time impact
> > of the function call overhead is significant here.

I think it is unnecessary. As pointed out that if the code is changed
as in my proposal we get:
 - real functions which can be profiled
 - reduce the number of code pieces which hold topology knowledge by
 one
 - a is_real_tile which is responsible for no measurable time:
 time   seconds   seconds    calls  ms/call  ms/call  name
 0.00     99.79     0.00    17447     0.00     0.00  is_real_tile

> +/* We're using a trick here.  The straightforward way to write
> +IN_RANGE() would be as
> +
> +  0 <= (a) && (a) < b
> +
> +however, since we know that b is always positive and we know
> +that the bit-pattern of a negative signed int is the same as the
> +bit-pattern of a very large number when interpreted as an unsigned
> +int, we can do away with the extra check.  */
> +
> +#define IN_RANGE(a,b) \
> +  (((unsigned) (a)) < ((unsigned) (b)))
> +

No. This have to be IN_RANGE_0 or IN_RANGE_ZERO.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "When C++ is your hammer, everything looks like a thumb."
    -- Steven M. Haflich


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