about summary refs log tree commit diff
path: root/src/nix-env
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
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')
-rw-r--r--src/nix-env/nix-env.cc8
-rw-r--r--src/nix-env/user-env.cc4
2 files changed, 6 insertions, 6 deletions
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc
index 04f1016167a9..97a2bbdb7de0 100644
--- a/src/nix-env/nix-env.cc
+++ b/src/nix-env/nix-env.cc
@@ -1127,13 +1127,13 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
                                     attrs2["type"] = "bool";
                                     attrs2["value"] = v->boolean ? "true" : "false";
                                     xml.writeEmptyElement("meta", attrs2);
-                                } else if (v->type == tList) {
+                                } else if (v->isList()) {
                                     attrs2["type"] = "strings";
                                     XMLOpenElement m(xml, "meta", attrs2);
-                                    for (unsigned int j = 0; j < v->list.length; ++j) {
-                                        if (v->list.elems[j]->type != tString) continue;
+                                    for (unsigned int j = 0; j < v->listSize(); ++j) {
+                                        if (v->listElems()[j]->type != tString) continue;
                                         XMLAttrs attrs3;
-                                        attrs3["value"] = v->list.elems[j]->string.s;
+                                        attrs3["value"] = v->listElems()[j]->string.s;
                                         xml.writeEmptyElement("string", attrs3);
                                     }
                                 }
diff --git a/src/nix-env/user-env.cc b/src/nix-env/user-env.cc
index 35b1628e3c5c..9a20b94334f2 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);