aboutsummaryrefslogtreecommitdiff
path: root/build2/variable.ixx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-01-25 15:41:44 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-02-13 12:39:24 +0200
commit88f0780e34116c0441a8d8c58b8a8fd9fde4b1f5 (patch)
tree1240b36211772479dc1220712e0daed4e35ecd85 /build2/variable.ixx
parent61aa8e2b4bd7849838c04dc1f421c4760d88319f (diff)
Add model mutex, make var_pool const by default
Diffstat (limited to 'build2/variable.ixx')
-rw-r--r--build2/variable.ixx30
1 files changed, 8 insertions, 22 deletions
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