You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-25 15:37:42 +00:00
Optimize NodePath update when renaming or deleting nodes in the editor
Now the process uses a Map to lookup node pointers instead of iterating over all modified node paths in a list and comparing them for each property to check. The process also avoids checking properties with empty node paths and does an early exit on deleted nodes to avoid checking the node and its descendants. Also made a minor change in NodePath::rel_path_to() to avoid resizing a Vector many times for long paths (with copy-on-write each time). Now it's down to 2 resize calls in any case.
This commit is contained in:
@@ -244,19 +244,26 @@ NodePath NodePath::rel_path_to(const NodePath &p_np) const {
|
||||
common_parent--;
|
||||
|
||||
Vector<StringName> relpath;
|
||||
relpath.resize(src_dirs.size() + dst_dirs.size() + 1);
|
||||
|
||||
for (int i = src_dirs.size() - 1; i > common_parent; i--) {
|
||||
relpath.push_back("..");
|
||||
StringName *relpath_ptr = relpath.ptrw();
|
||||
|
||||
int path_size = 0;
|
||||
StringName back_str("..");
|
||||
for (int i = common_parent + 1; i < src_dirs.size(); i++) {
|
||||
relpath_ptr[path_size++] = back_str;
|
||||
}
|
||||
|
||||
for (int i = common_parent + 1; i < dst_dirs.size(); i++) {
|
||||
relpath.push_back(dst_dirs[i]);
|
||||
relpath_ptr[path_size++] = dst_dirs[i];
|
||||
}
|
||||
|
||||
if (relpath.size() == 0) {
|
||||
relpath.push_back(".");
|
||||
if (path_size == 0) {
|
||||
relpath_ptr[path_size++] = ".";
|
||||
}
|
||||
|
||||
relpath.resize(path_size);
|
||||
|
||||
return NodePath(relpath, p_np.get_subnames(), false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user