Use a more optimized g_bit_storage() when gcc is available. (#371670,

2007-01-09  Behdad Esfahbod  <behdad@gnome.org>

        * glib/gutils.h: Use a more optimized g_bit_storage() when gcc is
        available.  (#371670, Daniel Elstner)


svn path=/trunk/; revision=5234
This commit is contained in:
Behdad Esfahbod 2007-01-09 19:05:36 +00:00 committed by Behdad Esfahbod
parent 4e4967a305
commit 6b6fd9bac8
2 changed files with 7 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2007-01-09 Behdad Esfahbod <behdad@gnome.org>
* glib/gutils.h: Use a more optimized g_bit_storage() when gcc is
available. (#371670, Daniel Elstner)
2007-01-08 Matthias Clasen <mclasen@redhat.com>
* gthread/gthread-posix.c (g_thread_impl_init): Don't

View File

@ -305,7 +305,8 @@ G_INLINE_FUNC guint
g_bit_storage (gulong number)
{
#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__OPTIMIZE__)
return number ? GLIB_SIZEOF_LONG * 8 - __builtin_clzl(number) : 1;
return G_LIKELY (number) ?
((GLIB_SIZEOF_LONG * 8 - 1) ^ __builtin_clzl(number)) + 1 : 1;
#else
register guint n_bits = 0;