Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2003:
[Freeciv-Dev] Re: (PR#4381) some clean with get_map_tile(...) , get_map_
Home

[Freeciv-Dev] Re: (PR#4381) some clean with get_map_tile(...) , get_map_

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: bursig@xxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#4381) some clean with get_map_tile(...) , get_map_terrain(...), get_map_special(...) ...
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Wed, 11 Jun 2003 02:26:14 -0700
Reply-to: rt@xxxxxxxxxxxxxx

On Tue, 10 Jun 2003, Rafa³ Bursig wrote:
> > We call map_set_special() for a reason, and that reason is code
> > abstraction. This code is run very rarely (compared to other code) so
> > optimizing them in this way is not a good idea.
> >
> Yes I can agree with you but you don't lose code abstraction when add
> #define tile_set_special(ptile, special)      ptile->special |=
> special

The problem is I don't believe you will gain anything. The set operations
are called extremely few times compared to get operations. At the risk of
sounding like Raimar, can you back up this with some numbers to show that
these changes actually improve speed in a measurable way?

> Per... I know that in times of current/moderns CPU this type of coding
> can be replaced by good code
> abstraction/maintability/cleanest/etc. but it is still question of
> philosophy.

We have discussed this issue extensively in the past. Raimar wants to
improve speed by using inline massively all over the place. Mike wants to
do the same but instead with macros. We settled on a sort of compromise
that we only make functions into macros when there is a mesurable speed
gain from doing so. So far this has not been done, but IIRC it was said
that turning map_get_tile() into a macro could improve speed by several
percentages (10%?).

Removing some debug code from some of the map access macros and functions
can also boost speed by a lot (perhaps another 10%), especially in debug
mode. As someone who always runs in debug mode, I'd very much appreciate
if some of this debug code was turned off unless explicitly turned on for
example by manually changing an undef to a define in map.c. Usually we
don't need to debug the map code.

Jason/Raimar/Mike probably remember these things better than I do anyway.

  - Per




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