From 88f0780e34116c0441a8d8c58b8a8fd9fde4b1f5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 25 Jan 2017 15:41:44 +0200 Subject: Add model mutex, make var_pool const by default --- build2/variable.ixx | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'build2/variable.ixx') diff --git a/build2/variable.ixx b/build2/variable.ixx index bb97750..816f4bf 100644 --- a/build2/variable.ixx +++ b/build2/variable.ixx @@ -622,33 +622,19 @@ namespace build2 // variable_pool // - inline const variable* variable_pool:: - find (const string& n) - { - auto i (map_.find (&n)); - return i != map_.end () ? &i->second : nullptr; - } - inline const variable& variable_pool:: - insert (string n) + operator[] (const string& n) const { - // We are not overriding anything so skip the custom insert() checks. - // - auto p ( - insert ( - variable {move (n), nullptr, nullptr, variable_visibility::normal})); - - return p.first->second; + const variable* r (find (n)); + assert (r != nullptr); + return *r; } - - inline const variable& variable_pool:: - operator[] (const string& n) + inline const variable* variable_pool:: + find (const string& n) const { - if (const variable* v = find (n)) - return *v; - else - return insert (n); + auto i (map_.find (&n)); + return i != map_.end () ? &i->second : nullptr; } // variable_map::iterator_adapter -- cgit v1.1