aboutsummaryrefslogtreecommitdiff
path: root/build2/variable.ixx
diff options
context:
space:
mode:
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