Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2001:
[Freeciv-Dev] Re: Profiling Civserver again
Home

[Freeciv-Dev] Re: Profiling Civserver again

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Profiling Civserver again
From: Jason Dorje Short <jshort@xxxxxxxxxxxxx>
Date: Wed, 25 Jul 2001 00:43:14 -0400

Trent Piepho wrote:

> I see lots of places which iterate around the 8 neighbors of a tile,
> normalizing the coordinates each time.  If the tile isn't on the boundary of
> the map, and most tiles aren't, then all those normalizations are unnecessary.

A very good point, if true.

Only two normalizations should be necessary for this iteration, not
eight:

* X X

X   X

X X *

This way each individual X and Y coordinate is only normalized once. 
This might make more sense in the code if the x and y normalizations are
split up; i.e.

        normalize_map_x(int *x)
        normalize_map_y(int *y)

These can be inlined or macro'd as desired.  Nonetheless, doing it with
only two normalizations like this may require extra variables to be
added to the loop - a compromise might be more efficient.

jason


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