Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2001:
[Freeciv-Dev] Re: Profile.
Home

[Freeciv-Dev] Re: Profile.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gaute B Strokkenes <gs234@xxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Profile.
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 26 Sep 2001 10:59:49 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Wed, Sep 26, 2001 at 03:40:19AM +0200, Gaute B Strokkenes wrote:
> 
> I ran an all-AI game with a CVS snapshot from a couple of days back,
> with the below (abbreviated) results.  Interested parties can get the
> whole thing from <http://www.srcf.ucam.org/~gs234/gmon.txt.bz2>.
> 
> This largely confirms what I've said before; normalize_map_pos() takes
> a lot of time and is_real_tile() should definitely be replaced with a
> macro.

There is hope! After the removal of the DIR_DX array I made some
changes to catch any un-real map positions. There were none. So I
changed it to catch any non-normal(ized) map accesses. They came from
lines such as:

  enum tile_special_type spec_t=map_get_special(pcity->x+x-2, pcity->y+y-2);
  enum tile_terrain_type tile_t=map_get_terrain(pcity->x+x-2, pcity->y+y-2);

The proposed patch would get rid of these. Although I haven't checked
I'm sure that there are none or only a very few non-normal(ized) map
accesses left. So we can in theory remove a lot of the is_real_tile
and normalize_map_pos calls in map_get_tile and co. However for the
ability to check this in the long run I would like to propose the
following:

#define CHECK_MAP_POS(x,y) do{\
    int dx = x, dy = y; \
    assert(normalize_map_pos(&dx, &dy)); \
    assert(x == dx && y == dy); \
  } while(0)

So map_get_tile would be like:

struct tile *map_get_tile(int x, int y)
{
  CHECK_MAP_POS(x,y);

  return map.tiles + map_inx(x, y);
}

CHECK_MAP_POS can now check for 
 - un-real map position or for
 - non-normal(ized) map positions or
 - can be a noop

This can be tied to NDEBUG or something other.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 Make a software that is foolproof, and only fools will want to use it.


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