[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[xml] proposed patch to hash function



This is a proposed patch for the hash function in libxml2 - according to
my benchmarking, it should give ~ 1 - 2 % of speed advantage. I hoped to
also finish teh second stage of the patch, but that is not quite ready for
public consumption yet.

	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	16 Jun 2002 16:46:11 -0000
@@ -66,20 +66,17 @@
     if (name != NULL) {
 	value += 30 * (*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]