Skip to content

Commit 186edd1

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 589dd0b commit 186edd1

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
@@ -1128,7 +1128,7 @@ template <> struct Hasher<Term> {
11281128
};
11291129
} // namespace __private__
11301130

1131-
template <HashAlgorithm A = HashAlgorithm::INTERNAL, typename T>
1131+
template <HashAlgorithm A = HashAlgorithm::PHASH2, typename T>
11321132
inline static std::uint64_t hash(const T &value, std::uint64_t salt = 0) {
11331133
return __private__::Hasher<T>::hash(A, value, salt);
11341134
}
@@ -1199,13 +1199,13 @@ inline static std::uint64_t hash(HashAlgorithm algorithm, const T &value,
11991199
namespace std {
12001200
template <> struct hash<::fine::Term> {
12011201
size_t operator()(const ::fine::Term &term) noexcept {
1202-
return ::fine::hash(term);
1202+
return ::fine::hash<::fine::HashAlgorithm::PHASH2>(term);
12031203
}
12041204
};
12051205

12061206
template <> struct hash<::fine::Atom> {
12071207
size_t operator()(const ::fine::Term &term) noexcept {
1208-
return ::fine::hash(term);
1208+
return ::fine::hash<::fine::HashAlgorithm::PHASH2>(term);
12091209
}
12101210
};
12111211
} // namespace std

0 commit comments

Comments
 (0)