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:
parent
0f9d2b3570
commit
e0b290c34f
@ -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. */
|
||||||
|
Loading…
Reference in New Issue
Block a user