mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-01 00:10:11 +01:00
shared: optimize nm_hash_str() for NULL to not use siphash24()
This commit is contained in:
parent
3751cceeec
commit
c3d98a3df6
2 changed files with 8 additions and 5 deletions
|
|
@ -171,6 +171,10 @@ test_nm_hash (void)
|
|||
g_assert (nm_hash_static (0));
|
||||
g_assert (nm_hash_static (777));
|
||||
|
||||
g_assert (nm_hash_str (NULL));
|
||||
g_assert (nm_hash_str (""));
|
||||
g_assert (nm_hash_str ("a"));
|
||||
|
||||
_test_hash_str ("");
|
||||
_test_hash_str ("a");
|
||||
_test_hash_str ("aa");
|
||||
|
|
|
|||
|
|
@ -127,11 +127,10 @@ nm_hash_str (const char *str)
|
|||
{
|
||||
NMHashState h;
|
||||
|
||||
if (str) {
|
||||
nm_hash_init (&h, 1867854211u);
|
||||
nm_hash_update_str (&h, str);
|
||||
} else
|
||||
nm_hash_init (&h, 842995561u);
|
||||
if (!str)
|
||||
return nm_hash_static (1867854211u);
|
||||
nm_hash_init (&h, 1867854211u);
|
||||
nm_hash_update_str (&h, str);
|
||||
return nm_hash_complete (&h);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue