Nonportable code in C++ support

Matthew Woehlke mw_triad at users.sourceforge.net
Fri Feb 15 19:14:15 UTC 2008


Esben Mose Hansen wrote:
> It wouldn't break. It's a hash function, it's going to get moduloed with some 
> smallish number anyway. The hash function just need a reasonable chance to 
> get different results for different pointers, fast. The latter is the reason 
> why I wouldn't bitshift it with size_t, even though those bits would likely 
> nearly always be zero.

Isn't this a *really* good reason to strip the last couple bits? I.e. 
because otherwise with a small table you will *always* get collisions 
due to the last 2-4 bits always being 0?

Seriously, how long does a bit-shift operation take? It's measured in 
single-digit /cycles/ after all... It's measurable compared to the cost 
of calling the hash function, but not compared to much else.

-- 
Matthew
A pool hall put up a sign in their front window that read: "Profound 
language prohibited within." I could just imagine some people discussing 
the meaning of life and being told to take it outside. -- Scott Adams





More information about the KDevelop-devel mailing list