Add Dictionary.merge()

This commit is contained in:
kobewi 2022-04-04 18:46:55 +02:00
parent 3aa83a0235
commit a0915e6dee
4 changed files with 18 additions and 0 deletions

View file

@ -269,6 +269,14 @@ void Dictionary::clear() {
_p->variant_map.clear();
}
void Dictionary::merge(const Dictionary &p_dictionary, bool p_overwrite) {
for (const KeyValue<Variant, Variant> &E : p_dictionary._p->variant_map) {
if (p_overwrite || !has(E.key)) {
this->operator[](E.key) = E.value;
}
}
}
void Dictionary::_unref() const {
ERR_FAIL_COND(!_p);
if (_p->refcount.unref()) {