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/libexpr/value-to-json.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libexpr/value-to-json.cc') diff --git a/src/libexpr/value-to-json.cc b/src/libexpr/value-to-json.cc index b08d824975aa..b0cf85e21f18 100644 --- a/src/libexpr/value-to-json.cc +++ b/src/libexpr/value-to-json.cc @@ -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; } -- cgit 1.4.1