Re: [Nautilus-list] fixing the fact that updating menus takes a lot of time



Seth Nickell <snickell stanford edu> writes:
> Havoc was discussing ways to fix this recently, actually, particularly
> the memory usage (apparently caused by linearly scanning the entire XML
> tree on every update)...so maybe somebody is working on it?

Well, let's not play the telephone game ;-) 

I said it scans lots of attribute lists, which is a linear search
through a linked list with a strcmp() on each node.  xmlGetProp() and
a couple Bonobo functions related to this show up in the profile (but
aren't the only bonobo-ui-handler things in the profile).

One thing that would probably help is:
 
 struct Node 
 {
    char *label;
    GdkPixbuf *icon;
    guint accel_key;
    ...
 };

 label = node->label;
 icon = node->icon;

Replacing:

 label = xmlGetProp (node, "label");
 icon = xmlGetProp (node, "icon");
 accel = xmlGetProp (node, "accel");

 /* ... parse attribute values ... */

 free (label);
 free (icon);
 free (accel);

Using the DOM tree as your primary representation is big time bloated.
To make it really fast, you might parse with SAX building up a custom
node struct as above, then merge from the struct Node instead of doing
the merge with DOM trees. xmlNode is a *huge* data structure with lots
of overhead unless you're actually interested in all the details of
the XML. (Which is not a negative comment about libxml, just the
nature of the DOM, libxml is doing what it has to do to implement
this.)

Havoc







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