1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 00:11:17 +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

@ -76,15 +76,15 @@ Value * findAlongAttrPath(EvalState & state, const string & attrPath,
else if (apType == apIndex) {
if (v->type != tList)
if (!v->isList())
throw TypeError(
format("the expression selected by the selection path %1% should be a list but is %2%")
% attrPath % showType(*v));
if (attrIndex >= v->list.length)
if (attrIndex >= v->listSize())
throw Error(format("list index %1% in selection path %2% is out of range") % attrIndex % attrPath);
v = v->list.elems[attrIndex];
v = v->listElems()[attrIndex];
}
}