aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-07-25 17:45:00 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-07-25 17:45:00 +0200
commit90e4f3c37b097d71176e20b530b83a5dc31e3d42 (patch)
tree0cc6aeacff5d2284df8ff1afca0259bef6e7d256
parent21acf9701d5f26ccc8c76775b0a3e1616e3b4ddd (diff)
Implement case-insensitive path hashing for Windows
-rw-r--r--libbutl/path.hxx16
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
}
};
}