aboutsummaryrefslogtreecommitdiff
path: root/build2/variable.ixx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-10-12 14:51:27 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 08:05:07 +0200
commit8d2e541ab1aa24140eb680fb046e49a4a3f0bbd2 (patch)
tree57401f85aeaa2e3d53534bcb9df007dffafccbac /build2/variable.ixx
parent04e382b0af66057f19c6dce66c43316cbd3cb23c (diff)
Various design/implementation cleanups
Diffstat (limited to 'build2/variable.ixx')
-rw-r--r--build2/variable.ixx29
1 files changed, 25 insertions, 4 deletions
diff --git a/build2/variable.ixx b/build2/variable.ixx
index 393a796..5c9118b 100644
--- a/build2/variable.ixx
+++ b/build2/variable.ixx
@@ -591,12 +591,33 @@ namespace build2
// variable_pool
//
- inline const variable& variable_pool::
+ inline const variable* variable_pool::
find (const string& n)
{
- auto p (variable_pool_base::insert (
- variable {n, nullptr, nullptr, variable_visibility::normal}));
- return *p.first;
+ auto i (map_.find (&n));
+ return i != map_.end () ? &i->second : nullptr;
+ }
+
+ inline const variable& variable_pool::
+ insert (string n)
+ {
+ // 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;
+ }
+
+
+ inline const variable& variable_pool::
+ operator[] (const string& n)
+ {
+ if (const variable* v = find (n))
+ return *v;
+ else
+ return insert (n);
}
// variable_map::iterator_adapter