summaryrefslogtreecommitdiffstats
path: root/editor/rename_dialog.cpp
diff options
context:
space:
mode:
authorA Thousand Ships <96648715+AThousandShips@users.noreply.github.com>2024-04-15 15:18:34 +0200
committerA Thousand Ships <96648715+AThousandShips@users.noreply.github.com>2024-05-04 16:08:55 +0200
commit955d5affa857ec1f358c56da8fb1ff4ab6590704 (patch)
treeb667ac9f6f62bff17ce032683c0eb09727660555 /editor/rename_dialog.cpp
parent7ebc866418b075df58cbe4e31fcf8b0c3acd70a1 (diff)
downloadredot-engine-955d5affa857ec1f358c56da8fb1ff4ab6590704.tar.gz
Reduce and prevent unnecessary random-access to `List`
Random-access access to `List` when iterating is `O(n^2)` (`O(n)` when accessing a single element) * Removed subscript operator, in favor of a more explicit `get` * Added conversion from `Iterator` to `ConstIterator` * Remade existing operations into other solutions when applicable
Diffstat (limited to 'editor/rename_dialog.cpp')
-rw-r--r--editor/rename_dialog.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp
index e63b90c0ac..9fca334e7c 100644
--- a/editor/rename_dialog.cpp
+++ b/editor/rename_dialog.cpp
@@ -591,12 +591,12 @@ void RenameDialog::rename() {
undo_redo->create_action(TTR("Batch Rename"), UndoRedo::MERGE_DISABLE, root_node, true);
// Make sure to iterate reversed so that child nodes will find parents.
- for (int i = to_rename.size() - 1; i >= 0; --i) {
- Node *n = root_node->get_node(to_rename[i].first);
- const String &new_name = to_rename[i].second;
+ for (List<Pair<NodePath, String>>::Element *E = to_rename.back(); E; E = E->prev()) {
+ Node *n = root_node->get_node(E->get().first);
+ const String &new_name = E->get().second;
if (!n) {
- ERR_PRINT("Skipping missing node: " + to_rename[i].first.get_concatenated_subnames());
+ ERR_PRINT("Skipping missing node: " + E->get().first.get_concatenated_subnames());
continue;
}
scene_tree_editor->rename_node(n, new_name);