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(); }
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; }

View file

@ -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();