Re: a bit about gnome-libs



Jeff Garzik <jgarzik@pobox.com> writes:

> Is there any advantage to using stack allocation routines, aside from the
> fact that you don't have to free() the results?

alloca() is much faster.  Say, alloca: 1 cycle, malloc()+free(): 100
cycles or more.

> In any case, a configure.in check for strdupa should probably accompany
> this patch, and do a s/ifdef strdupa/ifdef HAVE_STRDUPA/

Not necessary, believe me.  strdupa() always is a macro.  It can't be
a function and therefore #ifdef is just fine.  The only problem could
be if some system defines strdupa with another semantic.  But I don't
know about any such definition especially since it has to be in the
global namespace.

> g_strsplit() or smart use of g_strdelimit() may be preferred
> for GNOME hackers, since they are guaranteed to exist on all systems.

But they are slow compared to the carefully written strtok_r/strsep
functions.  I really don't understand why all these g_* functions are
used even on systems which have equivalent functionality already
available.  People spent considerable amounts of time on optimizing
the libc functions.  All this work gets lost when using the wrappers.
I'll write sometime soon a bit more on performance.

-- 
---------------.      drepper at gnu.org  ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com   `------------------------



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