Skip to content

Commit 9ac131c

Browse files
ezbrcopybara-github
authored andcommitted
Reorder members of MixingHashState to comply with Google C++ style guide ordering of type declarations, static constants, ctors, non-ctor functions.
PiperOrigin-RevId: 769667612 Change-Id: I1ebee3bedbb5fb408a7a213fc6076db7afad1ce5
1 parent 76fd1e9 commit 9ac131c

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

absl/hash/internal/hash.h

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,14 +1052,14 @@ class ABSL_DLL MixingHashState : public HashStateBase<MixingHashState> {
10521052
using uint128 = absl::uint128;
10531053
#endif // ABSL_HAVE_INTRINSIC_INT128
10541054

1055-
static constexpr uint64_t kMul =
1056-
uint64_t{0xdcb22ca68cb134ed};
1057-
10581055
template <typename T>
10591056
using IntegralFastPath =
10601057
conjunction<std::is_integral<T>, is_uniquely_represented<T>,
10611058
FitsIn64Bits<T>>;
10621059

1060+
static constexpr uint64_t kMul =
1061+
uint64_t{0xdcb22ca68cb134ed};
1062+
10631063
public:
10641064
// Move only
10651065
MixingHashState(MixingHashState&&) = default;
@@ -1093,14 +1093,37 @@ class ABSL_DLL MixingHashState : public HashStateBase<MixingHashState> {
10931093
}
10941094

10951095
private:
1096-
// Invoked only once for a given argument; that plus the fact that this is
1097-
// move-only ensures that there is only one non-moved-from object.
1098-
MixingHashState() : state_(Seed()) {}
1099-
11001096
friend class MixingHashState::HashStateBase;
11011097
template <typename H>
11021098
friend H absl::hash_internal::hash_weakly_mixed_integer(H,
11031099
WeaklyMixedInteger);
1100+
// Allow the HashState type-erasure implementation to invoke
1101+
// RunCombinedUnordered() directly.
1102+
friend class absl::HashState;
1103+
friend struct CombineRaw;
1104+
1105+
// For use in Seed().
1106+
static const void* const kSeed;
1107+
1108+
// Invoked only once for a given argument; that plus the fact that this is
1109+
// move-only ensures that there is only one non-moved-from object.
1110+
MixingHashState() : state_(Seed()) {}
1111+
1112+
// Workaround for MSVC bug.
1113+
// We make the type copyable to fix the calling convention, even though we
1114+
// never actually copy it. Keep it private to not affect the public API of the
1115+
// type.
1116+
MixingHashState(const MixingHashState&) = default;
1117+
1118+
explicit MixingHashState(uint64_t state) : state_(state) {}
1119+
1120+
// Combines a raw value from e.g. integrals/floats/pointers/etc. This allows
1121+
// us to be consistent with IntegralFastPath when combining raw types, but
1122+
// optimize Read1To3 and Read4To8 differently for the string case.
1123+
static MixingHashState combine_raw(MixingHashState hash_state,
1124+
uint64_t value) {
1125+
return MixingHashState(Mix(hash_state.state_ ^ value, kMul));
1126+
}
11041127

11051128
static MixingHashState combine_weakly_mixed_integer(
11061129
MixingHashState hash_state, WeaklyMixedInteger value) {
@@ -1130,27 +1153,6 @@ class ABSL_DLL MixingHashState : public HashStateBase<MixingHashState> {
11301153
return MixingHashState::combine(std::move(state), unordered_state);
11311154
}
11321155

1133-
// Allow the HashState type-erasure implementation to invoke
1134-
// RunCombinedUnordered() directly.
1135-
friend class absl::HashState;
1136-
friend struct CombineRaw;
1137-
1138-
// Workaround for MSVC bug.
1139-
// We make the type copyable to fix the calling convention, even though we
1140-
// never actually copy it. Keep it private to not affect the public API of the
1141-
// type.
1142-
MixingHashState(const MixingHashState&) = default;
1143-
1144-
explicit MixingHashState(uint64_t state) : state_(state) {}
1145-
1146-
// Combines a raw value from e.g. integrals/floats/pointers/etc. This allows
1147-
// us to be consistent with IntegralFastPath when combining raw types, but
1148-
// optimize Read1To3 and Read4To8 differently for the string case.
1149-
static MixingHashState combine_raw(MixingHashState hash_state,
1150-
uint64_t value) {
1151-
return MixingHashState(Mix(hash_state.state_ ^ value, kMul));
1152-
}
1153-
11541156
// Implementation of the base case for combine_contiguous where we actually
11551157
// mix the bytes into the state.
11561158
// Dispatch to different implementations of the combine_contiguous depending
@@ -1321,7 +1323,6 @@ class ABSL_DLL MixingHashState : public HashStateBase<MixingHashState> {
13211323
return static_cast<uint64_t>(reinterpret_cast<uintptr_t>(kSeed));
13221324
#endif
13231325
}
1324-
static const void* const kSeed;
13251326

13261327
uint64_t state_;
13271328
};

0 commit comments

Comments
 (0)