From b83801f8b3b48f4d69414401c8a51724946a8666 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 23 Jul 2015 22:05:09 +0200 Subject: 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. --- src/nix-env/user-env.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nix-env/user-env.cc') 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); -- cgit 1.4.1