Optimize NodePath update when renaming or deleting nodes in the editor #50319
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #50267 (regression from #49812).
Now the process uses a Map to lookup node pointers instead of iterating over all modified node paths in a list and comparing them one by one 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.
I haven't made precise measurements of the performance difference, but with several thousands of nodes with node paths to update, it takes only a couple seconds (about the same it takes without the node path check) as opposed to freezing the editor completely (at least for several minutes).
Project used for tests on 3.x (modified MRP from #50267):
Delete.node.test.zip