From 6417a4e6af2b7732ec0da6af24f1a56f7cdada3f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 31 Mar 2016 09:01:50 +0200 Subject: Set part of variable override implementation --- build2/variable.ixx | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) (limited to 'build2/variable.ixx') diff --git a/build2/variable.ixx b/build2/variable.ixx index 67f8c56..a4d7dc3 100644 --- a/build2/variable.ixx +++ b/build2/variable.ixx @@ -552,37 +552,14 @@ namespace build2 return !p->empty (); } + // variable_pool + // inline const variable& variable_pool:: - find (string n, const variable_visibility* vv, const build2::value_type* t) + find (const string& n) { - auto r ( - insert ( - variable { - move (n), - t, - vv != nullptr ? *vv : variable_visibility::normal})); - const variable& v (*r.first); - - // Update type? - // - if (!r.second && t != nullptr && v.type != t) - { - assert (v.type == nullptr); - const_cast (v).type = t; // Not changing the key. - } - - // Change visibility? While this might at first seem like a bad idea, - // it can happen that the variable lookup happens before any values - // were set, in which case the variable will be entered with the - // default visibility. - // - if (!r.second && vv != nullptr && v.visibility != *vv) - { - assert (v.visibility == variable_visibility::normal); // Default. - const_cast (v).visibility = *vv; // Not changing the key. - } - - return v; + auto p (variable_pool_base::insert ( + variable {n, nullptr, nullptr, variable_visibility::normal})); + return *p.first; } // variable_map::iterator_adapter -- cgit v1.1