Re: glib.h suggestion: update_hash functions



> you don't really want to call orther functions from hash functions,
> KISS, bite the apple and implement your own specialized hash function
> for that case, there were enough examples posted already to work from.

KISS?

So if I have two strings that I need to hash, you think that this:

    guint hash (gconstpointer v)
    {
        TwoStrings *t = v;
        const char *p;
        guint h = 0;
        for (p = t->string_1; *p != '\0'; p += 1)
            h = ( h << 5 ) - h  + *p;
        for (p = t->string_2; *p != '\0'; p += 1)
            h = ( h << 5 ) - h  + *p;
        return h;
    }

is simpler than this:

    guint hash (gconstpointer v)
    {
        TwoStrings *t = v;
        gint h = g_str_hash (t->string_1);
        return g_str_update_hash (h, t->string_2);
    }

?

    -- Darin



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]