Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2001:
[Freeciv-Dev] Re: map_adjust_x()

[Freeciv-Dev] Re: map_adjust_x()

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: Gaute B Strokkenes <gs234@xxxxxxxxx>
Subject: [Freeciv-Dev] Re: map_adjust_x()
From: Thue <thue@xxxxxxx>
Date: Wed, 14 Mar 2001 23:40:01 +0100

On Friday 09 March 2001 00:08, Falk Hueffner wrote:
> Thue <thue@xxxxxxx> writes:
> > Right now map_adjust_x only adjusts values in the range
> > [-map.xsize;map.xsize*2], but values outside that range are possible as
> > input (though rare).
> >
> > So the correct thing to do is to use modulus.
> Please do some timings with this change. Integer modulo is about the
> slowest opcode modern CPUS have, it often takes 10-20 cycles. (Not to
> mention older Alphas, which have no modulo opcode at all...)
>       Falk

But on the other hand we do away with a conditional if; might not be that big 
a penalty.
You could do it without the modulo with a
   while (x >= map.xsize) x -= map.xsize;
Those two should be benchmarked.
As a further note it would be much nicer if map_adjust_xy() was inline 
functions and not macros...

Gaute B Strokkenes said he was going to go through and make lots of stuff 
inline, benchmarking as he goes. If he still plans on doing that could he 
also include this optimization? :)

-Thue *who is doing as little freeciving as possible right now*

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