Allow returning Dictionary after merging
This commit is contained in:
@ -249,6 +249,7 @@ void Dictionary::clear() {
|
||||
}
|
||||
|
||||
void Dictionary::merge(const Dictionary &p_dictionary, bool p_overwrite) {
|
||||
ERR_FAIL_COND_MSG(_p->read_only, "Dictionary is in read-only state.");
|
||||
for (const KeyValue<Variant, Variant> &E : p_dictionary._p->variant_map) {
|
||||
if (p_overwrite || !has(E.key)) {
|
||||
operator[](E.key) = E.value;
|
||||
@ -256,6 +257,12 @@ void Dictionary::merge(const Dictionary &p_dictionary, bool p_overwrite) {
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary Dictionary::merged(const Dictionary &p_dictionary, bool p_overwrite) const {
|
||||
Dictionary ret = duplicate();
|
||||
ret.merge(p_dictionary, p_overwrite);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Dictionary::_unref() const {
|
||||
ERR_FAIL_NULL(_p);
|
||||
if (_p->refcount.unref()) {
|
||||
|
||||
Reference in New Issue
Block a user