Add SpookyHashV2
authorTudor Bosman <tudorb@fb.com>
Wed, 10 Oct 2012 21:11:25 +0000 (14:11 -0700)
committerJordan DeLong <jdelong@fb.com>
Fri, 12 Oct 2012 04:34:04 +0000 (21:34 -0700)
commit148cba11ab1b0d20f17485bd80fcc7e7214f5cca
treeba8df96dc254a31a73f57fede4bbba35be180a74
parent057837098c41af5345cb91b7591846ab7df4e2c1
Add SpookyHashV2

Summary:
SpookyHashV2 is backwards incompatible with V1.  I renamed the existing
SpookyHash class to SpookyHashV1 (and fixed all uses); the new class is
called SpookyHashV2.

From http://burtleburtle.net/bob/hash/spooky.html:

Both V1 and V2 pass all the tests. V2 corrects two oversights in V1:

In the short hash, there was a d = length that should have been d += length,
which means some entropy got dropped on the floor. It passed the tests anyhow,
but fixing this probably means more distinct info from the message makes it
into the result.

The long hash always ended in mix()+end(), but only end() was needed. Removing
the extra call to mix() makes all long hashes faster by a small constant
amount.

Test Plan: test added; unicorn compiles

Reviewed By: andrei.alexandrescu@fb.com

FB internal diff: D597173
folly/Hash.h
folly/Makefile.am
folly/SpookyHashV1.cpp [new file with mode: 0644]
folly/SpookyHashV1.h [new file with mode: 0644]
folly/SpookyHashV2.cpp [new file with mode: 0644]
folly/SpookyHashV2.h [new file with mode: 0644]
folly/test/Makefile.am
folly/test/SpookyHashV1Test.cpp [new file with mode: 0644]
folly/test/SpookyHashV2Test.cpp [new file with mode: 0644]