Enlightenment CVS committal
Author : raster
Project : e17
Module : libs/evas
Dir : e17/libs/evas/src/lib/data
Modified Files:
evas_hash.c
Log Message:
use djb2 hash for evas_hash too
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/evas/src/lib/data/evas_hash.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- evas_hash.c 28 Nov 2005 15:18:00 -0000 1.16
+++ evas_hash.c 5 Dec 2005 04:03:22 -0000 1.17
@@ -8,14 +8,13 @@
static inline int
_evas_hash_gen(const char *key)
{
- unsigned int hash_num = 0, i;
+ unsigned int hash_num = 5381;
const unsigned char *ptr;
-
+
if (!key) return 0;
-
- for (i = 0, ptr = (unsigned char *)key; *ptr; ptr++, i++)
- hash_num ^= ((int)(*ptr) | ((int)(*ptr) << 8)) >> (i % 8);
-
+ for (ptr = (unsigned char *)key; *ptr; ptr++)
+ hash_num = (hash_num * 33) ^ *ptr;
+
hash_num &= 0xff;
return (int)hash_num;
}
@@ -109,7 +108,7 @@
_evas_hash_alloc_error = 1;
return hash;
};
- el->key = ((unsigned char *)el) + sizeof(struct _Evas_Hash_El);
+ el->key = ((char *)el) + sizeof(struct _Evas_Hash_El);
strcpy(el->key, key);
el->data = (void *)data;
hash_num = _evas_hash_gen(key);
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs