From 90e4f3c37b097d71176e20b530b83a5dc31e3d42 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 25 Jul 2017 17:45:00 +0200 Subject: Implement case-insensitive path hashing for Windows --- libbutl/path.hxx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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& p) const noexcept { +#ifndef _WIN32 return hash>::operator() (p.string ()); +#else + // Case-insensitive FNV hash. + // + const auto& s (p.string ()); + + size_t hash (static_cast (2166136261UL)); + for (size_t i (0), n (s.size ()); i != n; ++i) + { + hash ^= static_cast (butl::lcase (s[i])); + hash *= sizeof (size_t) == 4 + ? static_cast(16777619UL) + : static_cast(1099511628211ULL); + } + return hash; +#endif } }; } -- cgit v1.1