1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Modify Dictionary::operator== to do real key/value comparison with recursive support (and add unittests)

This commit is contained in:
Emmanuel Leblond
2020-02-01 07:04:14 +01:00
parent 78f86ff515
commit f9ba2efe1e
15 changed files with 1031 additions and 100 deletions

View File

@@ -1824,11 +1824,15 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
return Variant();
}
Variant Variant::duplicate(bool deep) const {
Variant Variant::duplicate(bool p_deep) const {
return recursive_duplicate(p_deep, 0);
}
Variant Variant::recursive_duplicate(bool p_deep, int recursion_count) const {
switch (type) {
case OBJECT: {
/* breaks stuff :(
if (deep && !_get_obj().ref.is_null()) {
if (p_deep && !_get_obj().ref.is_null()) {
Ref<Resource> resource = _get_obj().ref;
if (resource.is_valid()) {
return resource->duplicate(true);
@@ -1838,9 +1842,9 @@ Variant Variant::duplicate(bool deep) const {
return *this;
} break;
case DICTIONARY:
return operator Dictionary().duplicate(deep);
return operator Dictionary().recursive_duplicate(p_deep, recursion_count);
case ARRAY:
return operator Array().duplicate(deep);
return operator Array().recursive_duplicate(p_deep, recursion_count);
case PACKED_BYTE_ARRAY:
return operator Vector<uint8_t>().duplicate();
case PACKED_INT32_ARRAY: