[Freeciv-Dev] Re: [RFC] square_dxy_iterate
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Raimar Falke wrote:
On Sat, Feb 23, 2002 at 07:23:27AM -0500, Jason Short wrote:
Raimar Falke wrote:
On Fri, Feb 22, 2002 at 06:04:45PM -0500, Jason Short wrote:
Raimar Falke wrote:
From the profile of an autogame (with disabled CHECK_MAP_POS):
Flat profile:
Flat profile:
[...]
enum tech_state get_invention(struct player *pplayer, Tech_Type_id tech)
{
if (!tech_exists(tech)) {
return TECH_UNKNOWN;
}
return pplayer->research.inventions[tech].state;
}
should be replaced with
enum tech_state get_invention(struct player *pplayer, Tech_Type_id tech)
{
assert(tech >= 0 && tech <game.num_tech_types);
return pplayer->research.inventions[tech].state;
}
What is the purpose of tech_exists if it is not used? What if the set
of techs is not a continuous set (i.e. some values in
0..(game.num_tech_types-1) are not valid technologies)? If you're
really concerned about speed, make tech_exists an inline function.
I agree that an assert makes sense in this case (assuming the calling
code is intelligent about this, which if it isn't it should be), but it
should preferably be
assert(tech_exists(tech));
Note that this won't speed up things at all for a "standard" autogame,
but if you compile with --disable-debug it surely will.
if (!is_real_tile(x, y)) {
freelog(LOG_ERROR, "Trying to get nonexistant tile at %i,%i", x, y);
}
nearest_real_pos(&x, &y);
should be removed since map_inx has a CHECK_MAP_POS check.
I submitted a patch to bugs@freeciv some time ago to accomplish this (it
removed the nearest_real_pos call, which was the primary goal). See
PR#1211.
jason
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, (continued)
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Petr Baudis, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Raimar Falke, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Petr Baudis, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Raimar Falke, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Jason Short, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Raimar Falke, 2002/02/23
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate,
Jason Short <=
- [Freeciv-Dev] Re: [RFC] square_dxy_iterate, Raimar Falke, 2002/02/23
|
|