Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Re: [PATCH] is_normal_tile function
Home

[Freeciv-Dev] Re: [PATCH] is_normal_tile function

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Trent Piepho <xyzzy@xxxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [PATCH] is_normal_tile function
From: Roy Tate <roy_tate@xxxxxxxxx>
Date: Wed, 15 Aug 2001 16:51:56 -0700 (PDT)

Perhaps we should have a macro

#define RANGE_CHECK (p1, p2) ((unsigned)(p1) < (unsigned)(p2))

Then the code would be

 return RANGE_CHECK(y, map.ysize) && RANGE_CHECK(x, map.xsize);

Although this doesn't really tell the reader that y is checked
against map size.

Best Regards,

Roy Tate

P.S.  I am separately posting a short introduction

--- Trent Piepho <xyzzy@xxxxxxxxxxxxx> wrote:
> On Wed, 15 Aug 2001, Raimar Falke wrote:
>>> you might want to use Ross' geeky way of writing such
things:
>>> 
>>> return ((unsigned) y < (unsigned) map.ysize) && (....)
>>> 
>>> or am I as usual missing something?
>> 
>> It is interesting to see that even a simple function can be
>> obfuscated.
> 
> But it's faster!  I like it when I see clever optimizations
> that I wouldn't have thought of myself.  I wonder what would
> happen to if tried to compile that on some old 70s computer
> that didn't use twos compliment?



__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/


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