summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2016-02-17 23:21:38 +0100
committerLemonBoy <thatlemon@gmail.com>2016-06-05 16:24:55 +0200
commite0b290c34fc116c043f51396e2770821ec357522 (patch)
treefaed34982a1fb371789d5dbb7958a73d88339415 /src
parent0f9d2b35700db69c66c5878b5562852565753dd2 (diff)
downloadirssi-e0b290c34fc116c043f51396e2770821ec357522.zip
Update the g_istr_hash function to use the djb hash
Diffstat (limited to 'src')
-rw-r--r--src/core/misc.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/core/misc.c b/src/core/misc.c
index 48a49fa3..74ca4725 100644
--- a/src/core/misc.c
+++ b/src/core/misc.c
@@ -401,22 +401,15 @@ int g_istr_cmp(gconstpointer v, gconstpointer v2)
return g_ascii_strcasecmp((const char *) v, (const char *) v2);
}
-/* a char* hash function from ASU */
-unsigned int g_istr_hash(gconstpointer v)
+guint g_istr_hash(gconstpointer v)
{
- const char *s = (const char *) v;
- unsigned int h = 0, g;
+ const signed char *p;
+ guint32 h = 5381;
- while (*s != '\0') {
- h = (h << 4) + i_toupper(*s);
- if ((g = h & 0xf0000000UL)) {
- h = h ^ (g >> 24);
- h = h ^ g;
- }
- s++;
- }
+ for (p = v; *p != '\0'; p++)
+ h = (h << 5) + h + g_ascii_toupper(*p);
- return h /* % M */;
+ return h;
}
/* Find `mask' from `data', you can use * and ? wildcards. */