aboutsummaryrefslogtreecommitdiff
path: root/butl
diff options
context:
space:
mode:
Diffstat (limited to 'butl')
-rw-r--r--butl/path-map34
1 files changed, 15 insertions, 19 deletions
diff --git a/butl/path-map b/butl/path-map
index f55bf18..fc66002 100644
--- a/butl/path-map
+++ b/butl/path-map
@@ -39,34 +39,30 @@ namespace butl
bool
operator() (const key_type& x, const key_type& y) const
{
- const auto& xs (x.string ());
- const auto& ys (y.string ());
+ const string_type& xs (x.string ());
+ const string_type& ys (y.string ());
-#ifdef _WIN32
return base::compare (xs.c_str (),
- xs.size (),
+ root (xs) ? 0 : xs.size (),
ys.c_str (),
- ys.size ()) < 0;
-#else
- return base::compare (xs.c_str (),
- x.root () ? 0 : xs.size (),
- ys.c_str (),
- y.root () ? 0 : ys.size ()) < 0;
-#endif
+ root (ys) ? 0 : ys.size ()) < 0;
}
bool
prefix (const key_type& p, const key_type& k) const
{
- const auto& ps (p.string ());
- const auto& ks (k.string ());
+ const string_type& ps (p.string ());
+ const string_type& ks (k.string ());
-#ifdef _WIN32
- return base::prefix (ps, ks);
-#else
- return base::prefix (p.root () ? string_type () : ps,
- k.root () ? string_type () : ks);
-#endif
+ return base::prefix (root (ps) ? string_type () : ps,
+ root (ks) ? string_type () : ks);
+ }
+
+ protected:
+ static bool
+ root (const string_type& p)
+ {
+ return p.size () == 1 && key_type::traits::is_separator (p[0]);
}
};