mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-07 12:54:00 +00:00
Use Fowler-Noll-Vo hash instead of std::hash
This commit is contained in:
parent
16922f8000
commit
de8d9b8db3
@ -71,8 +71,15 @@ namespace Misc::StringUtils
|
|||||||
|
|
||||||
std::size_t operator()(std::string_view str) const
|
std::size_t operator()(std::string_view str) const
|
||||||
{
|
{
|
||||||
// TODO avoid string copy
|
// FNV-1a
|
||||||
return std::hash<std::string>{}(lowerCase(str));
|
std::size_t hash{0xcbf29ce484222325ull};
|
||||||
|
constexpr std::size_t prime{0x00000100000001B3ull};
|
||||||
|
for(char c : str)
|
||||||
|
{
|
||||||
|
hash ^= static_cast<std::size_t>(toLower(c));
|
||||||
|
hash *= prime;
|
||||||
|
}
|
||||||
|
return hash;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user