diff --git a/src/mbgl/util/hash.hpp b/src/mbgl/util/hash.hpp index e49f73cf3..2786d8d46 100644 --- a/src/mbgl/util/hash.hpp +++ b/src/mbgl/util/hash.hpp @@ -25,10 +25,17 @@ template using TIterVal = std::enable_if_t::value, typename TIter::value_type>; } // namespace detail +template +constexpr T factor() { + // Default factor prime value from 64-bit FNV hash. + if constexpr (sizeof(T) == 8) return 1099511628211; + // for 32-bit hash + return 16777619; +} + /// Generate a hash key from a collection of integer values which doesn't depend on their order. /// Adapted from https://stackoverflow.com/a/76993810/135138 -/// Default factor prime value from 64-bit FNV hash. -template , TKey factor = 1099511628211LL> +template , TKey factor = factor()> TKey order_independent_hash(TIter cur, const TIter end) { detail::TIterVal sum = 0, product = 1; for (; cur != end; ++cur) {