summaryrefslogtreecommitdiff
path: root/src/lib/eina
diff options
context:
space:
mode:
authorsubhransu mohanty <sub.mohanty@samsung.com>2019-08-09 14:00:03 +0900
committerHermet Park <hermetpark@gmail.com>2019-08-09 14:00:03 +0900
commitda39f53b95c9bae298fb0145f152c2d81b5ebe31 (patch)
tree5d761afd799411cc29a6090e4f27db0127fc1667 /src/lib/eina
parent21bebe04225428731c9555d7905d295cbebb6dfd (diff)
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
Diffstat (limited to 'src/lib/eina')
-rw-r--r--src/lib/eina/eina_hash.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/lib/eina/eina_hash.c b/src/lib/eina/eina_hash.c
index 92c37e1..64d298b 100644
--- a/src/lib/eina/eina_hash.c
+++ b/src/lib/eina/eina_hash.c
@@ -1077,6 +1077,9 @@ eina_hash_find(const Eina_Hash *hash, const void *key)
1077 EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL); 1077 EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
1078 EINA_MAGIC_CHECK_HASH(hash); 1078 EINA_MAGIC_CHECK_HASH(hash);
1079 1079
1080 if (hash->population == 0)
1081 return NULL;
1082
1080 _eina_hash_compute(hash, key, &key_length, &key_hash); 1083 _eina_hash_compute(hash, key, &key_length, &key_hash);
1081 1084
1082 return eina_hash_find_by_hash(hash, key, key_length, key_hash); 1085 return eina_hash_find_by_hash(hash, key, key_length, key_hash);