about summary refs log tree commit diff
path: root/third_party
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-23T19·30+0100
committerVincent Ambo <tazjin@google.com>2020-05-23T19·30+0100
commitaf762abadc65ad9b2847a1fda33b8720a8070fd8 (patch)
tree03d5a0e7232703e70d8066c755891f526fa9e506 /third_party
parent55b1a4764752e8a52df326b7e6ec9809c28c3a8e (diff)
fix(3p/nix/libexpr): Ensure ExprOpUpdate merges into destination r/829
... this fixes nixpkgs eval!
Diffstat (limited to 'third_party')
-rw-r--r--third_party/nix/src/libexpr/eval.cc22
1 files changed, 5 insertions, 17 deletions
diff --git a/third_party/nix/src/libexpr/eval.cc b/third_party/nix/src/libexpr/eval.cc
index 4cfcc043be..60d3cd012d 100644
--- a/third_party/nix/src/libexpr/eval.cc
+++ b/third_party/nix/src/libexpr/eval.cc
@@ -1223,7 +1223,7 @@ void ExprOpImpl::eval(EvalState& state, Env& env, Value& v) {
   mkBool(v, !state.evalBool(env, e1, pos) || state.evalBool(env, e2, pos));
 }
 
-void ExprOpUpdate::eval(EvalState& state, Env& env, Value& v) {
+void ExprOpUpdate::eval(EvalState& state, Env& env, Value& dest) {
   Value v1;
   Value v2;
   state.evalAttrs(env, e1, v1);
@@ -1231,23 +1231,11 @@ void ExprOpUpdate::eval(EvalState& state, Env& env, Value& v) {
 
   state.nrOpUpdates++;
 
-  if (v1.attrs->empty()) {
-    v = v2;
-    return;
-  }
-  if (v2.attrs->empty()) {
-    v = v1;
-    return;
-  }
-
-  state.mkAttrs(v, /* capacity = */ 0);
-
-  /* Merge the sets, preferring values from the second set.  Make
-     sure to keep the resulting vector in sorted order. */
-  v.attrs->merge(v1.attrs);
-  v.attrs->merge(v2.attrs);
+  state.mkAttrs(dest, /* capacity = */ 0);
 
-  state.nrOpUpdateValuesCopied += v.attrs->size();
+  /* Merge the sets, preferring values from the second set. */
+  dest.attrs->merge(*v1.attrs);
+  dest.attrs->merge(*v2.attrs);
 }
 
 void ExprOpConcatLists::eval(EvalState& state, Env& env, Value& v) {