diff --git a/daemon/str.c b/daemon/str.c index 71a8ca636..e00aa01d2 100644 --- a/daemon/str.c +++ b/daemon/str.c @@ -2,25 +2,14 @@ #include #include +/* adapted from g_str_hash() from glib */ guint str_hash(gconstpointer ss) { const str *s = ss; - guint ret = 0; + guint ret = 5381; str it = *s; - while (it.len >= sizeof(guint)) { - guint *x = (void *) it.s; - ret ^= *x; - it.s += sizeof(guint); - it.len -= sizeof(guint); - } - while (it.len >= sizeof(gushort)) { - gushort *x = (void *) it.s; - ret ^= *x; - it.s += sizeof(gushort); - it.len -= sizeof(gushort); - } while (it.len > 0) { - ret ^= *it.s; + ret = (ret << 5) + ret + *it.s; it.s++; it.len--; }