diff options
author | Thomas Haller <thaller@redhat.com> | 2017-11-16 11:40:19 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-11-16 11:49:51 +0100 |
commit | 3751cceeec2bdf246c04e5bd846086e6feeeb7b6 (patch) | |
tree | e0a49969fa1272ffea3884de7205b094f85e4e76 | |
parent | 6fbd280b35d4f5b903857ff332739dabb21989d5 (diff) | |
download | NetworkManager-3751cceeec2bdf246c04e5bd846086e6feeeb7b6.tar.gz |
shared: inline fast-path for hash _get_hash_key()
-rw-r--r-- | shared/nm-utils/nm-hash-utils.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/shared/nm-utils/nm-hash-utils.c b/shared/nm-utils/nm-hash-utils.c index f1e4bd9f9e..4cfb62bd50 100644 --- a/shared/nm-utils/nm-hash-utils.c +++ b/shared/nm-utils/nm-hash-utils.c @@ -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) { |