Re: [dev] The mysterious 31

From: Jacob Todd <jaketodd422_AT_gmail.com>
Date: Wed, 4 Aug 2010 08:23:18 -0400

On Wed, Aug 04, 2010 at 05:01:56AM +0100, David Tweed wrote:
> It's also worth remembering that K & R was written at a time many
> decades ago when performance aspects of computer architecture were a
> lot, lot simpler. Apparently they have
>
> #define HASHSIZE 101
>
> which given that there's no really efficient way of computing % for
> arbitrary numbers is going to be quite slow (particularly if the
> strings are short), which is why hashes for modern machines use table
> sizes that avoid needing a mod. (There are other things that are slow
> on modern architectures that modern hash functions avoid.) I'd use K&R
> for the C syntax and some of the higher level ideas of programming,
> but not try to understand good hashing technology from there.
I wasn't trying to understand good hashing technology, I was in the dark
why the number 31 was being used. I understand now, though.

Received on Wed Aug 04 2010 - 14:23:18 CEST

This archive was generated by hypermail 2.2.0 : Wed Aug 04 2010 - 14:36:01 CEST