diff options
author | Vincent Ambo <mail@tazj.in> | 2020-07-16T18·31+0100 |
---|---|---|
committer | tazjin <mail@tazj.in> | 2020-07-16T18·51+0000 |
commit | cb3d9675084f735c099c211edc4c8472f97a0578 (patch) | |
tree | 4888a8fdc264735fccca27ec86b25f5b69446724 /third_party/nix/src/libexpr/eval.cc | |
parent | 1ba5aa293bac0cd07421d5d1ba92c7fd8e2a5754 (diff) |
refactor(3p/nix/libexpr): Use range insertion to merge nix::Bindings r/1320
Instead of manually iterating over the two bindings to be combined, this adds a new static method on the Bindings class which merges two attribute sets by calling the range insertion operator over them. In some anecdotal tests, this can lead to a ~10% speed bump - depending on the specific operation. Change-Id: I5dea03b0589a83a789d3a8a0fc81d0d9e6598371 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1216 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
Diffstat (limited to 'third_party/nix/src/libexpr/eval.cc')
-rw-r--r-- | third_party/nix/src/libexpr/eval.cc | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/third_party/nix/src/libexpr/eval.cc b/third_party/nix/src/libexpr/eval.cc index a834e097a5cf..2b825bfd2788 100644 --- a/third_party/nix/src/libexpr/eval.cc +++ b/third_party/nix/src/libexpr/eval.cc @@ -19,6 +19,7 @@ #include "libexpr/eval-inline.hh" #include "libexpr/function-trace.hh" +#include "libexpr/value.hh" #include "libstore/derivations.hh" #include "libstore/download.hh" #include "libstore/globals.hh" @@ -1240,11 +1241,9 @@ void ExprOpUpdate::eval(EvalState& state, Env& env, Value& dest) { state.nrOpUpdates++; - state.mkAttrs(dest, v1.attrs->size() + v2.attrs->size()); - - // Merge the sets, preferring values from the second set. - dest.attrs->merge(*v1.attrs); - dest.attrs->merge(*v2.attrs); + clearValue(dest); + dest.type = tAttrs; + dest.attrs = Bindings::Merge(*v1.attrs, *v2.attrs); } void ExprOpConcatLists::eval(EvalState& state, Env& env, Value& v) { |