From 3053f55528dbecb08ddb55fa94546a98af06e3e1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 19 Jan 2018 09:06:39 +0200 Subject: Reimplement prefix_map::find_sup() to iterate over key, not entries --- libbutl/prefix-map.mxx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'libbutl/prefix-map.mxx') diff --git a/libbutl/prefix-map.mxx b/libbutl/prefix-map.mxx index 882f46e..85d7635 100644 --- a/libbutl/prefix-map.mxx +++ b/libbutl/prefix-map.mxx @@ -71,6 +71,20 @@ LIBBUTL_MODEXPORT namespace butl compare (p.c_str (), pn, k.c_str (), pn == kn ? pn : pn + 1) == 0); } + // If the key is not empty, convert the key to its prefix and return + // true. Return false otherwise. + // + bool + prefix (K& k) const + { + if (k.empty ()) + return false; + + size_type p (k.rfind (d_)); + k.resize (p != K::npos ? p : 0); + return true; + } + protected: int compare (const C* x, size_type xn, -- cgit v1.1