diff options
author | Abseil Team <absl-team@google.com> | 2020-11-23 17:05:17 -0800 |
---|---|---|
committer | Gennadiy Rozental <rogeeff@google.com> | 2020-11-24 02:43:25 -0500 |
commit | 5d8fc9192245f0ea67094af57399d7931d6bd53f (patch) | |
tree | 99d50d3b52bbd768ee5f5c1d7ecf8c46678e7192 /absl/hash/internal/hash.cc | |
parent | e19260fd7dbef881492fd73891e0be5bd4a09b95 (diff) | |
download | abseil-5d8fc9192245f0ea67094af57399d7931d6bd53f.tar.gz abseil-5d8fc9192245f0ea67094af57399d7931d6bd53f.tar.bz2 abseil-5d8fc9192245f0ea67094af57399d7931d6bd53f.zip |
Export of internal Abseil changes
--
fcedaa5714efab8738446fa21620b827a40a3458 by Derek Mauro <dmauro@google.com>:
Uses Wyhash in the implementation of absl::Hash for hashing sequences
of more than 16 bytes on some platforms.
Due to the per-process randomization of the seed used by absl::Hash, users
should not notice this change, other than possibly getting better performance.
This change only affects platforms where absl::uint128 is implemented
with an intrinsic (and where sizeof(size_t)==8) since Wyhash relies on
fast 128-bit multiplication for speed.
PiperOrigin-RevId: 343956735
--
085e108c760084f19caa21dbeb2118de2be3f8f0 by Abseil Team <absl-team@google.com>:
Internal change for cord ring
PiperOrigin-RevId: 343919274
--
4c333278ad14d6692f203074b902506008ad624a by Jorg Brown <jorg@google.com>:
Minimize strings_internal::StringConstant further, by removing the need for the compiler to instantiate a compile-time class function.
PiperOrigin-RevId: 343878568
--
71c3c8c7b7821b67997e3d5345aaec67f93f266f by Abseil Team <absl-team@google.com>:
Internal change
PiperOrigin-RevId: 343838259
GitOrigin-RevId: fcedaa5714efab8738446fa21620b827a40a3458
Change-Id: Ifb91895a82d11e743acd42fe97ab7fb70712b7df
Diffstat (limited to 'absl/hash/internal/hash.cc')
-rw-r--r-- | absl/hash/internal/hash.cc | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/absl/hash/internal/hash.cc b/absl/hash/internal/hash.cc index b44ecb3a..1433eb9d 100644 --- a/absl/hash/internal/hash.cc +++ b/absl/hash/internal/hash.cc @@ -18,9 +18,9 @@ namespace absl { ABSL_NAMESPACE_BEGIN namespace hash_internal { -uint64_t CityHashState::CombineLargeContiguousImpl32(uint64_t state, - const unsigned char* first, - size_t len) { +uint64_t HashState::CombineLargeContiguousImpl32(uint64_t state, + const unsigned char* first, + size_t len) { while (len >= PiecewiseChunkSize()) { state = Mix(state, absl::hash_internal::CityHash32(reinterpret_cast<const char*>(first), @@ -33,13 +33,11 @@ uint64_t CityHashState::CombineLargeContiguousImpl32(uint64_t state, std::integral_constant<int, 4>{}); } -uint64_t CityHashState::CombineLargeContiguousImpl64(uint64_t state, - const unsigned char* first, - size_t len) { +uint64_t HashState::CombineLargeContiguousImpl64(uint64_t state, + const unsigned char* first, + size_t len) { while (len >= PiecewiseChunkSize()) { - state = - Mix(state, absl::hash_internal::CityHash64(reinterpret_cast<const char*>(first), - PiecewiseChunkSize())); + state = Mix(state, Hash64(first, PiecewiseChunkSize())); len -= PiecewiseChunkSize(); first += PiecewiseChunkSize(); } @@ -48,7 +46,24 @@ uint64_t CityHashState::CombineLargeContiguousImpl64(uint64_t state, std::integral_constant<int, 8>{}); } -ABSL_CONST_INIT const void* const CityHashState::kSeed = &kSeed; +ABSL_CONST_INIT const void* const HashState::kSeed = &kSeed; + +// The salt array used by Wyhash. This array is NOT the mechanism used to make +// absl::Hash non-deterministic between program invocations. See `Seed()` for +// that mechanism. +// +// Any random values are fine. These values are just digits from the decimal +// part of pi. +// https://en.wikipedia.org/wiki/Nothing-up-my-sleeve_number +constexpr uint64_t kWyhashSalt[5] = { + uint64_t{0x243F6A8885A308D3}, uint64_t{0x13198A2E03707344}, + uint64_t{0xA4093822299F31D0}, uint64_t{0x082EFA98EC4E6C89}, + uint64_t{0x452821E638D01377}, +}; + +uint64_t HashState::WyhashImpl(const unsigned char* data, size_t len) { + return Wyhash(data, len, Seed(), kWyhashSalt); +} } // namespace hash_internal ABSL_NAMESPACE_END |