diff options
-rw-r--r-- | libbutl/path.hxx | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libbutl/path.hxx b/libbutl/path.hxx index 7e35ba5..26b076f 100644 --- a/libbutl/path.hxx +++ b/libbutl/path.hxx @@ -1133,7 +1133,23 @@ namespace std size_t operator() (const butl::basic_path<C, K>& p) const noexcept { +#ifndef _WIN32 return hash<basic_string<C>>::operator() (p.string ()); +#else + // Case-insensitive FNV hash. + // + const auto& s (p.string ()); + + size_t hash (static_cast<size_t> (2166136261UL)); + for (size_t i (0), n (s.size ()); i != n; ++i) + { + hash ^= static_cast<size_t> (butl::lcase (s[i])); + hash *= sizeof (size_t) == 4 + ? static_cast<size_t>(16777619UL) + : static_cast<size_t>(1099511628211ULL); + } + return hash; +#endif } }; } |