about summary refs log tree commit diff
path: root/src/libexpr/value.hh
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-10-09T11·08+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-10-09T11·08+0200
commit6bb4c0b712788c9cec9a1721ceb3c3a5c89c4181 (patch)
tree01883ac7eaf1010cc6eefde5c9d1e361b03a03cf /src/libexpr/value.hh
parent986fbd6fabdd37077718b1ecfeabae33424ed2c8 (diff)
mkList: Scrub better
Clearing v.app.right was not enough, because the length field of a
list only takes 32 bits, so the most significant 32 bits of v.app.left
(a.k.a. v.thunk.env) would remain. This could cause Boehm GC to
interpret it as a valid pointer.

This change reduces maximum RSS for evaluating the ‘tested’ job in
nixos/release-small.nix from 1.33 GiB to 0.80 GiB, and runtime by
about 8%.
Diffstat (limited to 'src/libexpr/value.hh')
-rw-r--r--src/libexpr/value.hh4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libexpr/value.hh b/src/libexpr/value.hh
index 408b5e087e1a..5f18f629e632 100644
--- a/src/libexpr/value.hh
+++ b/src/libexpr/value.hh
@@ -96,7 +96,7 @@ struct Value
    Value to ensure that the target isn't kept alive unnecessarily. */
 static inline void clearValue(Value & v)
 {
-    v.app.right = 0;
+    v.app.left = v.app.right = 0;
 }
 
 
@@ -118,8 +118,8 @@ static inline void mkBool(Value & v, bool b)
 
 static inline void mkNull(Value & v)
 {
+    clearValue(v);
     v.type = tNull;
-    v.app.left = v.app.right = 0; // scrub
 }