diff options
author | Tim Janik <timj@gtk.org> | 2000-02-14 21:38:52 +0000 |
---|---|---|
committer | Tim Janik <timj@src.gnome.org> | 2000-02-14 21:38:52 +0000 |
commit | 7aecb12ae74f327f893271b43cc14516fff4b122 (patch) | |
tree | 68af03de899a52feda741d285b6e1cb5b6e162c6 | |
parent | 7767686fda1578281f0bd84f5420a2acd9da3736 (diff) |
changed g_str_hash() to a 31 bit version based on a submission by Karl
Mon Feb 14 22:32:49 2000 Tim Janik <timj@gtk.org>
* gstring.c: changed g_str_hash() to a 31 bit version based on
a submission by Karl Nelson and hand optimized ad absurdum by
various people ;)
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-2-12 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 6 | ||||
-rw-r--r-- | glib/gstring.c | 26 | ||||
-rw-r--r-- | gstring.c | 26 |
10 files changed, 68 insertions, 32 deletions
@@ -1,3 +1,9 @@ +Mon Feb 14 22:32:49 2000 Tim Janik <timj@gtk.org> + + * gstring.c: changed g_str_hash() to a 31 bit version based on + a submission by Karl Nelson and hand optimized ad absurdum by + various people ;) + Fri Feb 4 19:39:38 2000 Tim Janik <timj@gtk.org> * configure.in: up version number to 1.2.7, interface age 7 and diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index be4aa2601..0fce89cc4 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,9 @@ +Mon Feb 14 22:32:49 2000 Tim Janik <timj@gtk.org> + + * gstring.c: changed g_str_hash() to a 31 bit version based on + a submission by Karl Nelson and hand optimized ad absurdum by + various people ;) + Fri Feb 4 19:39:38 2000 Tim Janik <timj@gtk.org> * configure.in: up version number to 1.2.7, interface age 7 and diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index be4aa2601..0fce89cc4 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +Mon Feb 14 22:32:49 2000 Tim Janik <timj@gtk.org> + + * gstring.c: changed g_str_hash() to a 31 bit version based on + a submission by Karl Nelson and hand optimized ad absurdum by + various people ;) + Fri Feb 4 19:39:38 2000 Tim Janik <timj@gtk.org> * configure.in: up version number to 1.2.7, interface age 7 and diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index be4aa2601..0fce89cc4 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,9 @@ +Mon Feb 14 22:32:49 2000 Tim Janik <timj@gtk.org> + + * gstring.c: changed g_str_hash() to a 31 bit version based on + a submission by Karl Nelson and hand optimized ad absurdum by + various people ;) + Fri Feb 4 19:39:38 2000 Tim Janik <timj@gtk.org> * configure.in: up version number to 1.2.7, interface age 7 and diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index be4aa2601..0fce89cc4 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,9 @@ +Mon Feb 14 22:32:49 2000 Tim Janik <timj@gtk.org> + + * gstring.c: changed g_str_hash() to a 31 bit version based on + a submission by Karl Nelson and hand optimized ad absurdum by + various people ;) + Fri Feb 4 19:39:38 2000 Tim Janik <timj@gtk.org> * configure.in: up version number to 1.2.7, interface age 7 and diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index be4aa2601..0fce89cc4 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,9 @@ +Mon Feb 14 22:32:49 2000 Tim Janik <timj@gtk.org> + + * gstring.c: changed g_str_hash() to a 31 bit version based on + a submission by Karl Nelson and hand optimized ad absurdum by + various people ;) + Fri Feb 4 19:39:38 2000 Tim Janik <timj@gtk.org> * configure.in: up version number to 1.2.7, interface age 7 and diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index be4aa2601..0fce89cc4 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +Mon Feb 14 22:32:49 2000 Tim Janik <timj@gtk.org> + + * gstring.c: changed g_str_hash() to a 31 bit version based on + a submission by Karl Nelson and hand optimized ad absurdum by + various people ;) + Fri Feb 4 19:39:38 2000 Tim Janik <timj@gtk.org> * configure.in: up version number to 1.2.7, interface age 7 and diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index be4aa2601..0fce89cc4 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +Mon Feb 14 22:32:49 2000 Tim Janik <timj@gtk.org> + + * gstring.c: changed g_str_hash() to a 31 bit version based on + a submission by Karl Nelson and hand optimized ad absurdum by + various people ;) + Fri Feb 4 19:39:38 2000 Tim Janik <timj@gtk.org> * configure.in: up version number to 1.2.7, interface age 7 and diff --git a/glib/gstring.c b/glib/gstring.c index 0ae4fabd4..2274a6a23 100644 --- a/glib/gstring.c +++ b/glib/gstring.c @@ -67,26 +67,20 @@ g_str_equal (gconstpointer v, gconstpointer v2) return strcmp ((const gchar*) v, (const gchar*)v2) == 0; } -/* a char* hash function from ASU */ +/* 31 bit hash function */ guint -g_str_hash (gconstpointer v) +g_str_hash (gconstpointer key) { - const char *s = (char*)v; - const char *p; - guint h=0, g; - - for(p = s; *p != '\0'; p += 1) { - h = ( h << 4 ) + *p; - if ( ( g = h & 0xf0000000 ) ) { - h = h ^ (g >> 24); - h = h ^ g; - } - } - - return h /* % M */; + const char *p = key; + guint h = *p; + + if (h) + for (p += 1; *p != '\0'; p++) + h = (h << 5) - h + *p; + + return h; } - /* String Chunks. */ @@ -67,26 +67,20 @@ g_str_equal (gconstpointer v, gconstpointer v2) return strcmp ((const gchar*) v, (const gchar*)v2) == 0; } -/* a char* hash function from ASU */ +/* 31 bit hash function */ guint -g_str_hash (gconstpointer v) +g_str_hash (gconstpointer key) { - const char *s = (char*)v; - const char *p; - guint h=0, g; - - for(p = s; *p != '\0'; p += 1) { - h = ( h << 4 ) + *p; - if ( ( g = h & 0xf0000000 ) ) { - h = h ^ (g >> 24); - h = h ^ g; - } - } - - return h /* % M */; + const char *p = key; + guint h = *p; + + if (h) + for (p += 1; *p != '\0'; p++) + h = (h << 5) - h + *p; + + return h; } - /* String Chunks. */ |