Skip to content

Commit 6ebc546

Browse files
committed
Change default hash to PHASH2
PHASH2 is guaranteed to be stable across ERTS instance boundaries, hence making this hashing algorihtm more stable. This change is expected to reduce the friction for users, as terms will always hash equal, no matter the ERTS version and instance.
1 parent 2708c3d commit 6ebc546

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

c_include/fine.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ template <> struct Hasher<Term> {
10981098
};
10991099
} // namespace __private__
11001100

1101-
template <HashAlgorithm A = HashAlgorithm::INTERNAL, typename T>
1101+
template <HashAlgorithm A = HashAlgorithm::PHASH2, typename T>
11021102
inline static std::uint64_t hash(const T &value, std::uint64_t salt = 0) {
11031103
return __private__::Hasher<T>::hash(A, value, salt);
11041104
}
@@ -1169,13 +1169,13 @@ inline static std::uint64_t hash(HashAlgorithm algorithm, const T &value,
11691169
namespace std {
11701170
template <> struct hash<::fine::Term> {
11711171
size_t operator()(const ::fine::Term &term) noexcept {
1172-
return ::fine::hash(term);
1172+
return ::fine::hash<::fine::HashAlgorithm::PHASH2>(term);
11731173
}
11741174
};
11751175

11761176
template <> struct hash<::fine::Atom> {
11771177
size_t operator()(const ::fine::Term &term) noexcept {
1178-
return ::fine::hash(term);
1178+
return ::fine::hash<::fine::HashAlgorithm::PHASH2>(term);
11791179
}
11801180
};
11811181
} // namespace std

0 commit comments

Comments
 (0)