about summary refs log tree commit diff
path: root/src/libexpr/value-to-json.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2015-07-23T20·05+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-07-23T20·05+0200
commitb83801f8b3b48f4d69414401c8a51724946a8666 (patch)
tree912be85806c1d0ebc49dfafc0431eca0ee928655 /src/libexpr/value-to-json.cc
parent14be783676adbb3517b2f73fee31c6f341575440 (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/value-to-json.cc')
-rw-r--r--src/libexpr/value-to-json.cc6
1 files changed, 3 insertions, 3 deletions
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;
         }