From 43038bbfcb53ccaecc8a258e4d07d0f489292361 Mon Sep 17 00:00:00 2001 From: ACB Date: Sun, 4 Feb 2024 14:21:03 +0100 Subject: [PATCH] Only recurse depth wise in `Tree::_count_selected_items` --- scene/gui/tree.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 10f4962c483..73a49fd427a 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -2587,12 +2587,8 @@ int Tree::_count_selected_items(TreeItem *p_from) const { } } - if (p_from->get_first_child()) { - count += _count_selected_items(p_from->get_first_child()); - } - - if (p_from->get_next()) { - count += _count_selected_items(p_from->get_next()); + for (TreeItem *c = p_from->get_first_child(); c; c = c->get_next()) { + count += _count_selected_items(c); } return count;