diff --git a/Source/cmString.hxx b/Source/cmString.hxx index f7dcb2bf97..16881ac84e 100644 --- a/Source/cmString.hxx +++ b/Source/cmString.hxx @@ -16,6 +16,8 @@ #include #include +#include + namespace cm { class String; @@ -961,8 +963,8 @@ struct hash result_type operator()(argument_type const& s) const noexcept { - result_type const h(std::hash{}(s.view())); - return h; + cm::string_view const v = s.view(); + return static_cast(rapidhash(v.data(), v.size())); } }; } diff --git a/Utilities/std/cm/bits/string_view.cxx b/Utilities/std/cm/bits/string_view.cxx index 4a18e2fa14..d89e9646b1 100644 --- a/Utilities/std/cm/bits/string_view.cxx +++ b/Utilities/std/cm/bits/string_view.cxx @@ -9,7 +9,7 @@ # include # include -# include +# include namespace cm { @@ -282,15 +282,7 @@ std::string& operator+=(std::string& s, string_view v) std::hash::result_type std::hash::operator()( argument_type const& s) const noexcept { - // FNV-1a hash. - static KWIML_INT_uint64_t const fnv_offset_basis = 0xcbf29ce484222325; - static KWIML_INT_uint64_t const fnv_prime = 0x100000001b3; - KWIML_INT_uint64_t h = fnv_offset_basis; - for (char const& c : s) { - h = h ^ KWIML_INT_uint64_t(KWIML_INT_uint8_t(c)); - h = h * fnv_prime; - } - return result_type(h); + return result_type(rapidhash(s.data(), s.size())); } #else // Avoid empty translation unit.