Skip to content

Use rapidhashNano on folly::hasher<string/range> #9617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions third-party/folly/src/folly/Range.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

#include <folly/Portability.h>
#include <folly/hash/SpookyHashV2.h>
#include <folly/hash/rapidhash.h>
#include <folly/lang/CString.h>
#include <folly/lang/Exception.h>
#include <folly/portability/Constexpr.h>
Expand Down Expand Up @@ -794,7 +795,7 @@ class Range {
}

// Do NOT use this function, which was left behind for backwards
// compatibility. Use SpookyHashV2 instead -- it is faster, and produces
// compatibility. Use rapidhashNano 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.)
//
Expand Down Expand Up @@ -1697,8 +1698,8 @@ struct hasher<
// can contain pointers and padding. Also, floating point numbers
// may be == without being bit-identical. size_t is less than 64
// bits on some platforms.
return static_cast<size_t>(
hash::SpookyHashV2::Hash64(r.begin(), r.size() * sizeof(T), 0));
return static_cast<size_t>(folly::hash::rapidhashNano(
reinterpret_cast<const char*>(r.begin()), r.size() * sizeof(T)));
}
};

Expand Down
Loading