diff options
-rw-r--r-- | build2/algorithm.cxx | 2 | ||||
-rw-r--r-- | build2/config/module.cxx | 14 | ||||
-rw-r--r-- | build2/scope.cxx | 14 | ||||
-rw-r--r-- | build2/variable.hxx | 2 |
4 files changed, 11 insertions, 21 deletions
diff --git a/build2/algorithm.cxx b/build2/algorithm.cxx index 2ea2d1a..7ef5267 100644 --- a/build2/algorithm.cxx +++ b/build2/algorithm.cxx @@ -364,7 +364,7 @@ namespace build2 string hint; auto rs (rules.size () == 1 ? make_pair (rules.begin (), rules.end ()) - : rules.find_prefix (hint)); + : rules.find_sub (hint)); for (auto i (rs.first); i != rs.second; ++i) { diff --git a/build2/config/module.cxx b/build2/config/module.cxx index 19b5125..4639d98 100644 --- a/build2/config/module.cxx +++ b/build2/config/module.cxx @@ -19,19 +19,7 @@ namespace build2 // prefix of this variable name. // auto& sm (saved_modules); - auto i (sm.end ()); - - if (!sm.empty ()) - { - i = sm.upper_bound (n); - - // Get the greatest less than, if any. We might still not be a - // suffix. And we still have to check the last element if - // upper_bound() returned end(). - // - if (i == sm.begin () || !sm.key_comp ().prefix ((--i)->first, n)) - i = sm.end (); - } + auto i (sm.find_sup (n)); // If no module matched, then create one based on the variable name. // diff --git a/build2/scope.cxx b/build2/scope.cxx index 01a60a0..6fca9fb 100644 --- a/build2/scope.cxx +++ b/build2/scope.cxx @@ -760,7 +760,7 @@ namespace build2 { // The first entry is ourselves. // - auto r (m.find_prefix (k)); + auto r (m.find_sub (k)); for (++r.first; r.first != r.second; ++r.first) { scope& c (r.first->second); @@ -793,7 +793,7 @@ namespace build2 { // Upgrade to root scope. // - auto r (m.find_prefix (k)); + auto r (m.find_sub (k)); for (++r.first; r.first != r.second; ++r.first) { scope& c (r.first->second); @@ -813,12 +813,14 @@ namespace build2 { scope_map_base& m (*this); - // Better implementation that should work but doesn't. - // -#if 0 assert (k.normalized (false)); // Allow non-canonical dir separators. + + // Using find_sup() seems to be slightly slower. + // +#if 1 auto i (m.find_sup (k)); - return i != m.end () ? i->second : const_cast<scope&> (*global_scope); + assert (i != m.end ()); // Should have global scope. + return i->second; #else // Normally we would have a scope for the full path so try that before // making any copies. diff --git a/build2/variable.hxx b/build2/variable.hxx index 61485b5..299ec71 100644 --- a/build2/variable.hxx +++ b/build2/variable.hxx @@ -1251,7 +1251,7 @@ namespace build2 pair<const_iterator, const_iterator> find_namespace (const variable& ns) const { - auto r (m_.find_prefix (ns)); + auto r (m_.find_sub (ns)); return make_pair (const_iterator (r.first, *this), const_iterator (r.second, *this)); } |