mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +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:
parent
14be783676
commit
b83801f8b3
11 changed files with 157 additions and 121 deletions
|
@ -71,11 +71,11 @@ void printValueAsJSON(EvalState & state, bool strict,
|
|||
break;
|
||||
}
|
||||
|
||||
case tList: {
|
||||
case tList1: case tList2: case tListN: {
|
||||
JSONList json(str);
|
||||
for (unsigned int n = 0; n < v.list.length; ++n) {
|
||||
for (unsigned int n = 0; n < v.listSize(); ++n) {
|
||||
json.elem();
|
||||
printValueAsJSON(state, strict, *v.list.elems[n], str, context);
|
||||
printValueAsJSON(state, strict, *v.listElems()[n], str, context);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue