diff options
author | Mark Fisher <fisherm@tce.com> | 2001-02-08 05:44:00 -0500 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 2001-02-09 19:25:16 +0000 |
commit | a6fe520e69b81614f687efd2cdbfdcd1bb40e201 (patch) | |
tree | a2a37a5d596be27d5093af180a50d3555f9c5be6 /hv.h | |
parent | 682a4d6ff488c90b285372b88adbfe46b909f779 (diff) | |
download | perl-a6fe520e69b81614f687efd2cdbfdcd1bb40e201.tar.gz |
RE: Biannual Competition to Improve Hashing Function
Date: Thu, 8 Feb 2001 10:44:00 -0500
Message-Id: <A5E22933E3D5D4118FFE00508BF373C706A52F@indyexch28.indy.tce.
Date: Thu, 8 Feb 2001 15:02:47 -0500
Message-Id: <A5E22933E3D5D4118FFE00508BF373C706A52B@indyexch28.indy.tce.
p4raw-id: //depot/perl@8750
Diffstat (limited to 'hv.h')
-rw-r--r-- | hv.h | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -43,14 +43,22 @@ struct xpvhv { }; /* hash a key */ +/* FYI: This is the "One-at-a-Time" algorithm by Bob Jenkins */ +/* from requirements by Colin Plumb. */ +/* (http://burtleburtle.net/bob/hash/doobs.html) */ #define PERL_HASH(hash,str,len) \ STMT_START { \ register const char *s_PeRlHaSh = str; \ register I32 i_PeRlHaSh = len; \ register U32 hash_PeRlHaSh = 0; \ - while (i_PeRlHaSh--) \ - hash_PeRlHaSh = hash_PeRlHaSh * 33 + *s_PeRlHaSh++; \ - (hash) = hash_PeRlHaSh + (hash_PeRlHaSh>>5); \ + while (i_PeRlHaSh--) { \ + hash_PeRlHaSh += *s_PeRlHaSh++; \ + hash_PeRlHaSh += (hash_PeRlHaSh << 10); \ + hash_PeRlHaSh ^= (hash_PeRlHaSh >> 6); \ + } \ + hash_PeRlHaSh += (hash_PeRlHaSh << 3); \ + hash_PeRlHaSh ^= (hash_PeRlHaSh >> 11); \ + (hash) = (hash_PeRlHaSh += (hash_PeRlHaSh << 15)); \ } STMT_END /* |