diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-07-23T20·05+0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-07-23T20·05+0200 |
commit | b83801f8b3b48f4d69414401c8a51724946a8666 (patch) | |
tree | 912be85806c1d0ebc49dfafc0431eca0ee928655 /src/libexpr/attr-path.cc | |
parent | 14be783676adbb3517b2f73fee31c6f341575440 (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/libexpr/attr-path.cc')
-rw-r--r-- | src/libexpr/attr-path.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libexpr/attr-path.cc b/src/libexpr/attr-path.cc index a4945111e0a8..55379f94b189 100644 --- a/src/libexpr/attr-path.cc +++ b/src/libexpr/attr-path.cc @@ -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]; } } |