Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2000:
[Freeciv-Dev] patch: (4/4) idex - generalize citycache (PR#342)
Home

[Freeciv-Dev] patch: (4/4) idex - generalize citycache (PR#342)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] patch: (4/4) idex - generalize citycache (PR#342)
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Sat, 22 Apr 2000 22:39:00 -0700 (PDT)

The fourth in a set of 4 patches.

This is the one which actually does something interesting :-)

This patch generalises the city "citycache" into "idex" = "ident index"
for both cities and units, in both server and client.  This is done
using hashes from id values to pointers (separate hashes for cities
and units, for code simplicity).

This patch _doesn't_ actually result in any significant speedup for a
typical game, because it turns out (eg, profiling) that typically id 
lookups do not currently contribute significantly to overall time
(at least for one reasonably large game I tried).  However I still 
think this patch is a good idea, because, eg:

- In future may make more use of ids (eg, "safe pointers"), especially
  after this patch makes lookups faster (O(1)).

- Could now remove limit that id values fit into unsigned short,
  without consequence of citycache array becoming potentially very large 
  in server.  (Ie, idex hash size will be based on number of elements,
  but not on highest id value.)  This would allow declaring that id 
  values are never re-used, simplifying things in server/client 
  relations.

- In client, probably no longer need optimisation of
  improvement_upkeep_asmiths() (in city.c).  This is good because
  this optimisation is probably impractical with future generalised
  improvements.

-- David

Attachment: idex4.diff.gz
Description: GNU Zip compressed data


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