Re: [Evolution-hackers] [maybe OT?] Code excerpts from Evolution

Hi Tom,

"evolution-2.0.2/e-util/e-memory.c uses a GTree to track memory "chunks" that can be freed. It uses a custom GCompareFunc, tree_compare, to order the _cleaninfo structures which point to freeable chunks."

This isn't quite right.  It doesn't use a gtree to track the chunks, it uses it to calculate the unused chunks.  Subtle difference - in that the tree is used as a one-off structure during the clean process, not as long-term tracking structure.

We probably have more interesting collection usage throughout the code, although some of the more interesting ones don't use glib.

We actually don't use g* collections for many things we might, because of efficiency & preference issues.  Evolution also has many of its own data structures, because the glib ones aren't flexible enough or suitable.  e.g. its own m-tree structures in several places, its own single and double-linked list implementations, etc.

e.g. edlist is a double-linked list implementation which has O(1) append and prepend, and O(1) removal of head and tail nodes.  GList has O(N) append and O(N) removal of the tail node.  This often leads to unecessary and inefficient code such as g_list_reverse, or having to manually track the tail node which is prone to coding mistakes.  It also means you can't re-use the same simple code as a stack, a queue, or an ordered list without a performance penalty in some of the cases - there are even more special api's for each case.

In general, the glib collections:
To put it bluntly, glib's data structures 'mostly suck', but they're there, and usually simple to use, so we use them sometimes.


On Mon, 2005-05-02 at 16:58 -0400, Tom Copeland wrote:
Howdy -

Here's a bit of Evolution "code publicity" I thought folks might be
interested in.  I'm working on a tutorial for IBM's developerWorks site
on the GLib collections - GSList, GHashTable, GTree, and all that.  As
part of the tutorial, I'm picking out excerpts of various collection
types from a couple of nice open source apps: Gaim, the GIMP, and,
naturally, Evolution.  

Here's a list of the references to Evolution that I've currently got in
the article:

If anyone has any suggestions/corrections to the descriptions of these
usages, please email me at tom infoether com (or here if you think it's
on-topic enough).  

Many thanks,

Tom Copeland
tom infoether com

evolution-hackers maillist  -  evolution-hackers lists ximian com

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]