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:
subhransu mohanty 2019-08-09 14:00:03 +09:00 committed by Hermet Park
parent 21bebe0422
commit da39f53b95
1 changed files with 3 additions and 0 deletions

View File

@ -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);