cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [PATCHES RFC 2/2] Optional hash table improvements

From: Jamie Lokier <jamie_at_shareable.org>
Date: Wed, 2 May 2007 16:01:17 +0100

Daniel Stenberg wrote:
> fd_key_compare seems to be in the same position.
>
> >return ((fd < (int)slots_num) ? fd : fd % (int)slots_num);
>
> Is this complication really necessary? I mean, why not just do it:
>
> return fd % (int)slots_num;

Presumably because "%" is relatively slow on a lot of processors?

Personally I use power-of-two size hash tables these days, so there is
no "%" operation required. There are good integer and string
power-of-two hash functions these days.

I am surprised and intrigued that adding the indirect function calls
for every hash operation results in a speed up, as the old hash
function was quite simple.

-- Jamie
Received on 2007-05-02