diff options
Diffstat (limited to 'third_party/nix/src/libexpr')
-rw-r--r-- | third_party/nix/src/libexpr/attr-set.cc | 11 | ||||
-rw-r--r-- | 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 495f9816c7aa..6310cc66b726 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 19d1c8f530e4..37e6d5e1ca8f 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(); |