mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 14:10:36 +01: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);
|
||||
|
||||
static const guint8 *volatile global_seed = NULL;
|
||||
|
||||
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
|
||||
* to use it as guint* or guint64* pointer. */
|
||||
static union {
|
||||
|
|
@ -80,6 +81,16 @@ _get_hash_key (void)
|
|||
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
|
||||
nm_hash_static (guint static_seed)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue