Skip to content

Commit

Permalink
Mix pointers twice in absl::Hash.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 714244777
Change-Id: I832f29fe195d13154469be8292d091291a8f928b
  • Loading branch information
ezbr authored and copybara-github committed Jan 10, 2025
1 parent 69b5bd1 commit 3f770c4
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions absl/hash/internal/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,8 @@ std::enable_if_t<std::is_pointer<T>::value, H> AbslHashValue(H hash_state,
// Due to alignment, pointers tend to have low bits as zero, and the next few
// bits follow a pattern since they are also multiples of some base value. The
// byte swap in WeakMix helps ensure we still have good entropy in low bits.
#if defined(__APPLE__) || defined(__ANDROID__) || defined(_MSC_VER) || \
defined(ABSL_HAVE_ADDRESS_SANITIZER) || defined(ABSL_HAVE_THREAD_SANITIZER)
// In these build modes, pointers may have less entropy so mix pointers twice.
// Mix pointers twice to ensure we have good entropy in low bits.
return H::combine(std::move(hash_state), v, v);
#endif
return H::combine(std::move(hash_state), v);
}

// AbslHashValue() for hashing nullptr_t
Expand Down

0 comments on commit 3f770c4

Please sign in to comment.