Godot Engine – Multi-platform 2D and 3D game engine
Speed up scene duplication by replacing `get_path_to` with `get_name`
HolonProduction1d2c3c7c027a
diff --git a/scene/main/node.cpp b/scene/main/node.cppindex 72997910687..72ddfb5a50f 100644--- a/scene/main/node.cpp+++ b/scene/main/node.cpp@@ -3097,7 +3097,7 @@ void Node::_duplicate_scripts(const Node *p_original, Node *p_copy, int p_flags)Node *original = p_original->get_child(i, false);// If using instantiation and the child structure changed, getting it by index will result in// fetching values from the wrong nodes. So use the slower (but more accurate) path method.- Node *copy = instantiated ? p_copy->get_node(p_original->get_path_to(original)) : p_copy->get_child(i, false);+ Node *copy = instantiated ? p_copy->get_node(NodePath({ original->get_name() }, false)) : p_copy->get_child(i, false);ERR_FAIL_NULL_MSG(copy, "Child node disappeared while duplicating.");_duplicate_scripts(original, copy, p_flags);}@@ -3161,7 +3161,7 @@ void Node::_duplicate_properties(const Node *p_root, const Node *p_original, NodNode *original = p_original->get_child(i, false);// If using instantiation and the child structure changed, getting it by index will result in// fetching values from the wrong nodes. So use the slower (but more accurate) path method.- Node *copy = instantiated ? p_copy->get_node(p_original->get_path_to(original)) : p_copy->get_child(i, false);+ Node *copy = instantiated ? p_copy->get_node(NodePath({ original->get_name() }, false)) : p_copy->get_child(i, false);ERR_FAIL_NULL_MSG(copy, "Child node disappeared while duplicating.");_duplicate_properties(p_root, original, copy, p_flags);}