Christopher Smith on 2 Sep 2003 22:06:45 -0000


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

[ALACPP] C++ version of Jenkins hash


So, the Jenkins hash is a really nice hash. Sample code can be found at:

http://burtleburtle.net/bob/c/lookup2.c

Unfortunately, it's written in ugly C. :-(

In particular, the "mix" function, isn't a function at all, but rather a
big hairy macro.

What I'd like to do is turn said macro into a nice inline function,
hoping I can convince the compiler to generate the same code as with the
macro. I was wondering as to people's thoughts on this. So far, my lame
attempt has been to do:

inline void mix(u_int32_t& a, u_int32_t& b, u_int32_t& c);

and hope the compiler is smart enough not to deref a pointer each time.
Anyone else have thoughts?

-- 
Christopher Smith <x@xxxxxxxx>
_______________________________________________
alacpp mailing list
alacpp@xxxxxxxxxxx
http://lists.ellipsis.cx/mailman/listinfo/alacpp