From 55b1a4764752e8a52df326b7e6ec9809c28c3a8e Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sat, 23 May 2020 20:29:05 +0100 Subject: refactor(3p/nix/libexpr): Make other 'const' in Bindings::merge --- third_party/nix/src/libexpr/attr-set.cc | 11 ++++------- third_party/nix/src/libexpr/attr-set.hh | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/third_party/nix/src/libexpr/attr-set.cc b/third_party/nix/src/libexpr/attr-set.cc index 495f9816c7..6310cc66b7 100644 --- a/third_party/nix/src/libexpr/attr-set.cc +++ b/third_party/nix/src/libexpr/attr-set.cc @@ -59,13 +59,10 @@ Bindings::iterator Bindings::begin() { return attributes_.begin(); } Bindings::iterator Bindings::end() { return attributes_.end(); } -void Bindings::merge(Bindings* other) { - // We want the values from the other attribute set to take - // precedence, but .merge() works the other way around. - // - // To work around that, we merge and then swap. - other->attributes_.merge(attributes_); - attributes_.swap(other->attributes_); +void Bindings::merge(const Bindings& other) { + for (auto& [key, value] : other.attributes_) { + this->attributes_[key] = value; + } } Bindings* Bindings::NewGC() { return new (GC) Bindings; } diff --git a/third_party/nix/src/libexpr/attr-set.hh b/third_party/nix/src/libexpr/attr-set.hh index 19d1c8f530..37e6d5e1ca 100644 --- a/third_party/nix/src/libexpr/attr-set.hh +++ b/third_party/nix/src/libexpr/attr-set.hh @@ -64,7 +64,7 @@ class Bindings { iterator end(); // Merge values from other into the current attribute - void merge(Bindings* other); + void merge(const Bindings& other); // ??? [[deprecated]] size_t capacity(); -- cgit 1.4.1