mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 18:18:03 +02:00
shared: inline fast-path for hash _get_hash_key()
This commit is contained in:
parent
6fbd280b35
commit
3751cceeec
1 changed files with 13 additions and 2 deletions
|
|
@ -35,10 +35,11 @@
|
||||||
|
|
||||||
G_STATIC_ASSERT (sizeof (guint) * HASH_KEY_SIZE_GUINT >= HASH_KEY_SIZE);
|
G_STATIC_ASSERT (sizeof (guint) * HASH_KEY_SIZE_GUINT >= HASH_KEY_SIZE);
|
||||||
|
|
||||||
|
static const guint8 *volatile global_seed = NULL;
|
||||||
|
|
||||||
static const guint8 *
|
static const guint8 *
|
||||||
_get_hash_key (void)
|
_get_hash_key_init (void)
|
||||||
{
|
{
|
||||||
static const guint8 *volatile global_seed = NULL;
|
|
||||||
/* the returned hash is aligned to guin64, hence, it is safe
|
/* the returned hash is aligned to guin64, hence, it is safe
|
||||||
* to use it as guint* or guint64* pointer. */
|
* to use it as guint* or guint64* pointer. */
|
||||||
static union {
|
static union {
|
||||||
|
|
@ -80,6 +81,16 @@ _get_hash_key (void)
|
||||||
return g_arr.v8;
|
return g_arr.v8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define _get_hash_key() \
|
||||||
|
({ \
|
||||||
|
const guint8 *_g; \
|
||||||
|
\
|
||||||
|
_g = global_seed; \
|
||||||
|
if (G_UNLIKELY (_g == NULL)) \
|
||||||
|
_g = _get_hash_key_init (); \
|
||||||
|
_g; \
|
||||||
|
})
|
||||||
|
|
||||||
guint
|
guint
|
||||||
nm_hash_static (guint static_seed)
|
nm_hash_static (guint static_seed)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue