forked from enlightenment/efl
eina/hash: optimize eina_hash_find() when hash is empty.
Summary: Check if hash is empty before computing the hash key and look inside the hash to find data. Note: could have called the eina_hash_population() api but didn't because of extra function call. Reviewers: Hermet Reviewed By: Hermet Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9531
This commit is contained in:
parent
21bebe0422
commit
da39f53b95
|
@ -1077,6 +1077,9 @@ eina_hash_find(const Eina_Hash *hash, const void *key)
|
|||
EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
|
||||
EINA_MAGIC_CHECK_HASH(hash);
|
||||
|
||||
if (hash->population == 0)
|
||||
return NULL;
|
||||
|
||||
_eina_hash_compute(hash, key, &key_length, &key_hash);
|
||||
|
||||
return eina_hash_find_by_hash(hash, key, key_length, key_hash);
|
||||
|
|
Loading…
Reference in New Issue