Permalink
Browse files

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
  • Loading branch information...
tudor authored and jdelong committed Oct 10, 2012
1 parent 0578370 commit 148cba11ab1b0d20f17485bd80fcc7e7214f5cca
View
@@ -22,7 +22,8 @@
#include <string>
#include <utility>
-#include "folly/SpookyHash.h"
+#include "folly/SpookyHashV1.h"
+#include "folly/SpookyHashV2.h"
/*
* Various hashing functions.
View
@@ -66,7 +66,8 @@ nobase_follyinclude_HEADERS = \
SmallLocks.h \
small_vector.h \
sorted_vector_types.h \
- SpookyHash.h \
+ SpookyHashV1.h \
+ SpookyHashV2.h \
StlAllocator.h \
String.h \
String-inl.h \
@@ -108,7 +109,8 @@ libfolly_la_SOURCES = \
FormatTables.cpp \
String.cpp \
Bits.cpp \
- SpookyHash.cpp
+ SpookyHashV1.cpp \
+ SpookyHashV2.cpp
libfolly_la_LIBADD = $(BOOST_THREAD_LIB) -lpthread
Oops, something went wrong.

0 comments on commit 148cba1

Please sign in to comment.