From 485517cf64c83c86f398b3df0d8cc3c1ce6566a5 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Sun, 3 Aug 2025 20:52:16 +0200 Subject: [PATCH] Use std::hash --- components/misc/strings/algorithm.hpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/components/misc/strings/algorithm.hpp b/components/misc/strings/algorithm.hpp index 9b42588780..681bc0607a 100644 --- a/components/misc/strings/algorithm.hpp +++ b/components/misc/strings/algorithm.hpp @@ -86,7 +86,7 @@ namespace Misc::StringUtils { using is_transparent = void; - constexpr std::size_t operator()(std::string_view str) const + std::size_t operator()(std::string_view str) const { // FNV-1a std::uint64_t hash{ 0xcbf29ce484222325ull }; @@ -96,16 +96,7 @@ namespace Misc::StringUtils hash ^= static_cast(toLower(c)); hash *= prime; } - if constexpr (sizeof(std::uint64_t) <= sizeof(std::size_t)) - return hash; - else if constexpr (sizeof(std::uint32_t) == sizeof(std::size_t)) - { - std::uint32_t low = hash & 0xFFFFFFFF; - std::uint32_t high = hash >> 32; - return low ^ high; - } - static_assert(sizeof(std::uint64_t) <= sizeof(std::size_t) || sizeof(std::uint32_t) == sizeof(std::size_t)); - return {}; + return std::hash()(hash); } };