1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 21:41:48 +02:00

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.
This commit is contained in:
Eelco Dolstra 2015-07-23 22:05:09 +02:00
parent 14be783676
commit b83801f8b3
11 changed files with 157 additions and 121 deletions

View file

@ -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);