[Freeciv-Dev] Re: Profiling Civserver again
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
"Ross W. Wetmore" wrote:
>
> Attached is a quick hack of my accumulated macro patches into map.c, map.h
> for yesterday's CVS.
I'm not sure how to fit these together, but I have made changes to
current CVS that do the following:
- Implement a single adjc_all_iterate macro, and make macros
adjc_iterate, adjc_dir_iterate, and adjc_cart_iterate aliases for it.
The macro works basically as Trent outlined, a single loop of one
variable using the DIR_DX2/DIR_DY2 variables. It does not yet use his
algorithm for dealing with border cases, but can easily be extended to
do so.
- Replace all appropriate loops with one of these macros. There were a
lot of them!
- Upgrade the loops to be consistent with the new system. In particular
(1) loops that use an optional cardinal-only variable are much easier to
handle and (2) everything in the code uses the DIR_DX2/DIR_DY2
directional system instead of the old DIR_DX/DIR_DY system [1].
- Removed the variables DIR_DX, DIR_DY, DIR_CART_DX, and DIR_CART_DY.
- Wrote a few simple macros, functions, and variables.
is_normal_map_pos(x, y) returns true iff (x, y) is in its normal
(canonical) form. get_dir(x, y) returns the direction from the (x,y)
pair. reverse(dir) returns the reverse of the direction [1]. DIR_NAMES
holds the names ("N", "NW", etc.) of each direction. is_cardinal(dir)
behaves as you would expect.
- Removed a few manual checks that map positions were real/normal, and
replaced them with is_real_tile/is_normal_map_pos calls.
[1] The biggest trouble I've had was figuring out that 128>>dir was
really supposed to be 1<<reverse(dir). That should have been commented!
> The real advantage is probably when you go through a lot of the current
> code and replace the index computations with loop variables, i.e. replace
> MAP(x,y) with a MAP1(_xy) or the equivalent to avoid the endemic
> map.xsize*y+x on every access using base loop variables x,y.
There are three advantages here: the adjc_dir_iterate macro is simpler
(and harder to mess up) than manual iteration. The new directional
system is _much_ easier to work with. Finally, enhancing freeciv to
allow different map wrapping systems will be slightly easier.
I haven't quite finished upgrading all references to DIR_DX/DIR_DY, but
when I do I'll send the patch along. Right now both server and (GTK)
client compile and run just fine (on an AI simulation). Obviously, it
should not be applied before 1.12.0.
jason
- [Freeciv-Dev] Re: Profiling Civserver again, (continued)
- [Freeciv-Dev] Re: Profiling Civserver again, Gaute B Strokkenes, 2001/07/29
- [Freeciv-Dev] Re: Profiling Civserver agai, Vasco Alexandre Da Silva Costa, 2001/07/29
- [Freeciv-Dev] Re: Profiling Civserver again, Thue Janus Kristensen, 2001/07/29
- [Freeciv-Dev] Re: Profiling Civserver again, Gaute B Strokkenes, 2001/07/29
- [Freeciv-Dev] Re: Profiling Civserver again, Ross W. Wetmore, 2001/07/29
- [Freeciv-Dev] Re: Profiling Civserver again, Ross W. Wetmore, 2001/07/29
- [Freeciv-Dev] Re: Profiling Civserver again,
Jason Dorje Short <=
- [Freeciv-Dev] Re: Profiling Civserver again, Trent Piepho, 2001/07/30
- Message not available
- [Freeciv-Dev] Re: Profiling Civserver again, Ross W. Wetmore, 2001/07/30
- Message not available
- Message not available
- Message not available
- Message not available
- [Freeciv-Dev] Re: Profiling Civserver again, Paul Zastoupil, 2001/07/31
- [Freeciv-Dev] Re: Profiling Civserver again, Jason Dorje Short, 2001/07/31
- [Freeciv-Dev] Re: Profiling Civserver again, Thue, 2001/07/31
- [Freeciv-Dev] Re: Profiling Civserver again, Ross W. Wetmore, 2001/07/31
- [Freeciv-Dev] Re: Profiling Civserver again, Gregory Berkolaiko, 2001/07/31
- [Freeciv-Dev] Re: Profiling Civserver again, Gregory Berkolaiko, 2001/07/29
[Freeciv-Dev] Re: Profiling Civserver again, 蔡恆華, 2001/07/31
|
|