refactor(3p/nix/libexpr): Make other 'const' in Bindings::merge

This commit is contained in:
Vincent Ambo 2020-05-23 20:29:05 +01:00
parent ab1fbd4c6e
commit 55b1a47647
2 changed files with 5 additions and 8 deletions

View file

@ -59,13 +59,10 @@ Bindings::iterator Bindings::begin() { return attributes_.begin(); }
Bindings::iterator Bindings::end() { return attributes_.end(); } Bindings::iterator Bindings::end() { return attributes_.end(); }
void Bindings::merge(Bindings* other) { void Bindings::merge(const Bindings& other) {
// We want the values from the other attribute set to take for (auto& [key, value] : other.attributes_) {
// precedence, but .merge() works the other way around. this->attributes_[key] = value;
// }
// To work around that, we merge and then swap.
other->attributes_.merge(attributes_);
attributes_.swap(other->attributes_);
} }
Bindings* Bindings::NewGC() { return new (GC) Bindings; } Bindings* Bindings::NewGC() { return new (GC) Bindings; }

View file

@ -64,7 +64,7 @@ class Bindings {
iterator end(); iterator end();
// Merge values from other into the current attribute // Merge values from other into the current attribute
void merge(Bindings* other); void merge(const Bindings& other);
// ??? // ???
[[deprecated]] size_t capacity(); [[deprecated]] size_t capacity();