Ethereal-dev: Re: [ethereal-dev] Ethereal memory leakage fix and feature enhancement

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Laurent Deniel <deniel@xxxxxxxxxxx>
Date: Sun, 08 Aug 1999 12:14:30 +0200
Guy Harris wrote:
> 
> > Some time ago, I made an improvement of the snprintf function (see
> > http://ethereal.zing.org/lists/ethereal-dev/199905/msg00108.html) because
> > some profiling tests show me that it was a particularly good point to
> > enhance.
> 
> Unfortunately, that helps only on platforms that don't have a version of
> "snprintf()"; on platforms that do, we use that one, rather than ours.

No, the patch contains also a new configure option to force the use of 
the built-in version.
 
>   %   cumulative   self              self     total
>  time   seconds   seconds    calls  ms/call  ms/call  name
>  45.4      15.05    15.05                             g_list_nth [1]
>  43.7      29.55    14.50                             g_list_last [2]

> Unfortunately, attempts to get the Nth element of a GList are linear in
> N, which means that if you, say, do something such as
> 
>         for (i = 0; i < M; M++)
>                 xxx = g_list_nth(list, i);
> 
> you have something quadratic in M....

Right.

> Many, quite possibly most, such sequences would work much better if,
> say, a GList cached the index of, and pointer to, the last element
> fetched with such a "g_list_xxx()" call, and, if the index in the next
> call was greater than or equal to the index of the last element fetched,
> started the scan at that element.  (It would, of course, flush the cache
> as necessary if the list changes.)
> 
> A GtkCList, as I remember, does those sorts of sequences.

Don't known. But this may be interesting.

--
Laurent DENIEL        | E-mail: deniel@xxxxxxxxxxx
Paris, FRANCE         |         laurent.deniel@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
                      | WWW   : http://www.worldnet.fr/~deniel
    All above opinions are personal, unless stated otherwise.