diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-06-06 23:38:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-06 23:38:29 +0200 |
commit | 83421cd06f8aeacc69d666e0e695333fdaa80377 (patch) | |
tree | 58a9c005ef6f029f8884120a4f1b6dee5bb9b008 /core/variant/dictionary.cpp | |
parent | 8fb004efbc6161d2adec9501c08cfc9a910086f6 (diff) | |
parent | a0915e6dee4e54563a98ca6adb8968dbdcea1af1 (diff) |
Merge pull request #59883 from KoBeWi/merge_this
Diffstat (limited to 'core/variant/dictionary.cpp')
-rw-r--r-- | core/variant/dictionary.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/core/variant/dictionary.cpp b/core/variant/dictionary.cpp index bda8c93a79..822021f440 100644 --- a/core/variant/dictionary.cpp +++ b/core/variant/dictionary.cpp @@ -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()) { |