about summary refs log tree commit diff
path: root/src/nix-env/user-env.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2015-07-23T20·05+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-07-23T20·05+0200
commitb83801f8b3b48f4d69414401c8a51724946a8666 (patch)
tree912be85806c1d0ebc49dfafc0431eca0ee928655 /src/nix-env/user-env.cc
parent14be783676adbb3517b2f73fee31c6f341575440 (diff)
Optimize small lists
The value pointers of lists with 1 or 2 elements are now stored in the
list value itself. In particular, this makes the "concatMap (x: if
cond then [(f x)] else [])" idiom cheaper.
Diffstat (limited to 'src/nix-env/user-env.cc')
-rw-r--r--src/nix-env/user-env.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/nix-env/user-env.cc b/src/nix-env/user-env.cc
index 35b1628e3c..9a20b94334 100644
--- a/src/nix-env/user-env.cc
+++ b/src/nix-env/user-env.cc
@@ -52,7 +52,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
         Path drvPath = keepDerivations ? i.queryDrvPath() : "";
 
         Value & v(*state.allocValue());
-        manifest.list.elems[n++] = &v;
+        manifest.listElems()[n++] = &v;
         state.mkAttrs(v, 16);
 
         mkString(*state.allocAttr(v, state.sType), "derivation");
@@ -69,7 +69,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
         state.mkList(vOutputs, outputs.size());
         unsigned int m = 0;
         for (auto & j : outputs) {
-            mkString(*(vOutputs.list.elems[m++] = state.allocValue()), j.first);
+            mkString(*(vOutputs.listElems()[m++] = state.allocValue()), j.first);
             Value & vOutputs = *state.allocAttr(v, state.symbols.create(j.first));
             state.mkAttrs(vOutputs, 2);
             mkString(*state.allocAttr(vOutputs, state.sOutPath), j.second);