From d0954351f53c0de0d2b0a0e0f422a40f82142d5c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 18 Jan 2018 11:41:23 +0200 Subject: Use prefix_map::find_sup/sub() --- build2/scope.cxx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'build2/scope.cxx') 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 (*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. -- cgit v1.1