1
0
mirror of https://github.com/irssi/irssi.git synced 2025-02-02 15:08:01 -05:00

Update the g_istr_hash function to use the djb hash

This commit is contained in:
LemonBoy 2016-02-17 23:21:38 +01:00
parent 0f9d2b3570
commit e0b290c34f

View File

@ -401,22 +401,15 @@ int g_istr_cmp(gconstpointer v, gconstpointer v2)
return g_ascii_strcasecmp((const char *) v, (const char *) v2); return g_ascii_strcasecmp((const char *) v, (const char *) v2);
} }
/* a char* hash function from ASU */ guint g_istr_hash(gconstpointer v)
unsigned int g_istr_hash(gconstpointer v)
{ {
const char *s = (const char *) v; const signed char *p;
unsigned int h = 0, g; guint32 h = 5381;
while (*s != '\0') { for (p = v; *p != '\0'; p++)
h = (h << 4) + i_toupper(*s); h = (h << 5) + h + g_ascii_toupper(*p);
if ((g = h & 0xf0000000UL)) {
h = h ^ (g >> 24);
h = h ^ g;
}
s++;
}
return h /* % M */; return h;
} }
/* Find `mask' from `data', you can use * and ? wildcards. */ /* Find `mask' from `data', you can use * and ? wildcards. */