From: Alexey Spiridonov <lesha@fb.com>
Date: Thu, 19 Mar 2015 00:12:09 +0000 (-0700)
Subject: Add comment about djb2 hash
X-Git-Tag: v0.32.0~8
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=db66df3bcee0c6b8fdc9f94879efa805e4001d83;p=folly.git

Add comment about djb2 hash

Summary:
In my tests, using djb2 was much worse for any sizable workload. Just use SpookyHashV2.

Test Plan: comment only

Reviewed By: tudorb@fb.com

Subscribers: trunkagent, folly-diffs@, yfeldblum

FB internal diff: D1906439

Signature: t1:1906439:1426117575:f88b7b28b578092c1716433e21150d423d4e94a7
---

diff --git a/folly/Range.h b/folly/Range.h
index 72b1345e..7401af6b 100644
--- a/folly/Range.h
+++ b/folly/Range.h
@@ -426,6 +426,11 @@ public:
     return b_[i];
   }
 
+  // Do NOT use this function, which was left behind for backwards
+  // compatibility.  Use SpookyHashV2 instead -- it is faster, and produces
+  // a 64-bit hash, which means dramatically fewer collisions in large maps.
+  // (The above advice does not apply if you are targeting a 32-bit system.)
+  //
   // Works only for Range<const char*> and Range<char*>
   uint32_t hash() const {
     // Taken from fbi/nstring.h:
@@ -916,6 +921,7 @@ operator>=(const T& lhs, const U& rhs) {
   return StringPiece(lhs) >= StringPiece(rhs);
 }
 
+// Do NOT use this, use SpookyHashV2 instead, see commment on hash() above.
 struct StringPieceHash {
   std::size_t operator()(const StringPiece str) const {
     return static_cast<std::size_t>(str.hash());