about summary refs log tree commit diff
path: root/src/libexpr/common-opts.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-09-19T14·49+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-09-19T14·49+0200
commit5b58991a71d15123c010bbbd7f08530dbc31173f (patch)
tree3cec3413ee43ddd8b46b950022e0741a7c166fd7 /src/libexpr/common-opts.cc
parent0342eb170500f726f11269d26a1f34cded5d3676 (diff)
Store Attrs inside Bindings
This prevents a double allocation per attribute set.
Diffstat (limited to 'src/libexpr/common-opts.cc')
-rw-r--r--src/libexpr/common-opts.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/libexpr/common-opts.cc b/src/libexpr/common-opts.cc
index 25f1e7117b76..c03d720bde82 100644
--- a/src/libexpr/common-opts.cc
+++ b/src/libexpr/common-opts.cc
@@ -25,17 +25,19 @@ bool parseAutoArgs(Strings::iterator & i,
 }
 
 
-void evalAutoArgs(EvalState & state, std::map<string, string> & in, Bindings & out)
+Bindings * evalAutoArgs(EvalState & state, std::map<string, string> & in)
 {
-    for (auto & i: in) {
+    Bindings * res = state.allocBindings(in.size());
+    for (auto & i : in) {
         Value * v = state.allocValue();
         if (i.second[0] == 'E')
             state.mkThunk_(*v, state.parseExprFromString(string(i.second, 1), absPath(".")));
         else
             mkString(*v, string(i.second, 1));
-        out.push_back(Attr(state.symbols.create(i.first), v));
+        res->push_back(Attr(state.symbols.create(i.first), v));
     }
-    out.sort();
+    res->sort();
+    return res;
 }