Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2005:
[Freeciv-Dev] (PR#11779) New genlist code
Home

[Freeciv-Dev] (PR#11779) New genlist code

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#11779) New genlist code
From: "Vasco Alexandre da Silva Costa" <vasc@xxxxxxxxxxxxxx>
Date: Tue, 4 Jan 2005 09:17:47 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11779 >

> [per - Mon Jan 03 20:24:39 2005]:
> 
> This is the new genlist code I've been whispering about in the corners for
> some time. It is not finished yet (still some valgrind warnings to track
> down, and a strange delay on quit), but it is at a 'needs comments' stage.
> 
> In short:
>  - nodes in the linked list are not deleted at once, but marked as deleted
>  - a master list called the tracker points to all lists
>  - new listname_list_free() method
>  - renamed listname_list_init(list) to *listname_list_new()
>  - when genlists_prune() is called from high-level code, all lists are
>    pruned for nodes marked as deleted
>  - genlists are now pointers instead of allocated on the stack, hence
>    no more
>       struct genlist mylist;
>    but
>       struct genlist *mylist;
> 
> This way of doing genlists is inherently safer, as deletion of the next
> node by called code (which is why we have unit_list_iterate_safe) is
> unproblematic.

I like the basic design of this code *much* better than that of the
previous implementation. But there are some things that should be done
differently IMHO.

One, it should be possible to create tracked and non-tracked
genlists. The tracker list would be a non-tracked genlist. Instead of
adding that special casing. (Non-tracked genlists wouldn't use GC but
simply free nodes?).

Two, I think you should try adding an extra integer field,
ndeleted, which has the number of deleted but non-freed nodes in a list,
to make pruning of lists faster. This should be benchmarked, to see
how much faster it made things.




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