Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2002:
[Freeciv-Dev] Re: [Patch] simple_ai_unit_type_iterate
Home

[Freeciv-Dev] Re: [Patch] simple_ai_unit_type_iterate

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [Patch] simple_ai_unit_type_iterate
From: Jason Short <vze2zq63@xxxxxxxxxxx>
Date: Fri, 08 Mar 2002 12:49:47 -0500
Reply-to: jdorje@xxxxxxxxxxxx

Raimar Falke wrote:
On Wed, Mar 06, 2002 at 12:47:52PM +0100, Raimar Falke wrote:

It turns out that is_ai_simple_military can be computed before the
game starts. The patch does this and replaces the calls with a new
iterate. Another 2.2% speedup.


Mike provided the idea to code the iterate in another form which
should be a bit faster. However I haven't made any measurements
yet. (HINT).

Aside from the potential buffer overflow (if there are U_LAST different units, all of which are ai_simple_military) it looks fine. Whether it's faster or not...I'd suggest first converting the code to use the iterator, then tweaking the iterator internals. I doubt any speed difference will be comparable to, say, inlining a single function...

Given that this piece of memory stays around for the life of the server and is only calculated once, why not make one pass to count the number of simple_military unit types, then allocate and make another pass to fill them in?

I'm not entirely happy with the name simple_ai_unit_type_iterate. "simple" just isn't very descriptive. I'd say "military_ai_unit_type_iterate" might be better, but not by much. Something understandable would probably be way too long...

jason



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