[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[xml] experimenting with the hash
- From: Sander Vesik <Sander Vesik Sun COM>
- To: xml gnome org
- Subject: [xml] experimenting with the hash
- Date: Mon, 10 Jun 2002 19:56:57 +0100 (BST)
attached is a patch that replaces the hash function in libxml2 with
another. It is my hope that the more work done per character during
hashing will pay off in more even disribution of the keys and thus less
collisions and cache misses. It did perfome slightly better than the
existing one for me. The function won't hash strings that are permutations
of each other to the same value.
I would be very interested if people tried it on a variety of machines and
sent me the results.
The function is from a paper by Ramakrishna and Zobel titled "Perfomance
in Practice of String Hashing Function". You can get it in citeseer.
Sander
you'll rescue me right?
in the exact same way that they never did
i'll be happy right?
when your healing powers kick in
Index: hash.c
===================================================================
RCS file: /cvs/gnome/gnome-xml/hash.c,v
retrieving revision 1.19
diff -u -r1.19 hash.c
--- hash.c 18 Mar 2002 19:37:03 -0000 1.19
+++ hash.c 10 Jun 2002 17:28:37 -0000
@@ -64,22 +64,19 @@
char ch;
if (name != NULL) {
- value += 30 * (*name);
+ value += (unsigned long)*name;
while ((ch = *name++) != 0) {
- /* value *= 31; */
- value += (unsigned long)ch;
+ value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);
}
}
if (name2 != NULL) {
while ((ch = *name2++) != 0) {
- /* value *= 31; */
- value += (unsigned long)ch;
+ value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);
}
}
if (name3 != NULL) {
while ((ch = *name3++) != 0) {
- /* value *= 31; */
- value += (unsigned long)ch;
+ value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);
}
}
return (value % table->size);
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]