raster pushed a commit to branch efl-1.20.

http://git.enlightenment.org/core/efl.git/commit/?id=2818e8d481990156d57b4d5ddff16dbf1673ff38

commit 2818e8d481990156d57b4d5ddff16dbf1673ff38
Author: Cedric Bail <[email protected]>
Date:   Tue Oct 17 16:11:25 2017 -0700

    eina: fix eina_hash_stringshared_new to actually compute the hash on the 
pointer.
    
    Before this patch, the key would always be zero and the hash would solely
    rely on the rbtree to be efficient. This improve the situation by using the 
pointer
    as the key during hash computation.
---
 src/lib/eina/eina_hash.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/lib/eina/eina_hash.c b/src/lib/eina/eina_hash.c
index b2d338d832..39a7a9c984 100644
--- a/src/lib/eina/eina_hash.c
+++ b/src/lib/eina/eina_hash.c
@@ -484,6 +484,12 @@ _eina_hash_del_by_key(Eina_Hash *hash, const void *key, 
const void *data)
    return _eina_hash_del_by_key_hash(hash, key, key_length, key_hash, data);
 }
 
+static int
+_eina_stringshared_hash(const void *key, int key_length EINA_UNUSED)
+{
+   return eina_hash_superfast(&key, sizeof (void*));
+}
+
 static unsigned int
 _eina_string_key_length(const char *key)
 {
@@ -840,7 +846,7 @@ eina_hash_stringshared_new(Eina_Free_Cb data_free_cb)
 {
    return eina_hash_new(NULL,
                         EINA_KEY_CMP(_eina_stringshared_key_cmp),
-                        EINA_KEY_HASH(eina_hash_superfast),
+                        EINA_KEY_HASH(_eina_stringshared_hash),
                         data_free_cb,
                         EINA_HASH_BUCKET_SIZE);
 }

-- 


Reply via email to