Skip to content

Commit 795ed8f

Browse files
committed
Faster Node::get_child_count()
There is no need to update the children cache when including internal nodes in the count.
1 parent 8f78e75 commit 795ed8f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

scene/main/node.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,13 +1922,12 @@ void Node::_update_children_cache_impl() const {
19221922

19231923
int Node::get_child_count(bool p_include_internal) const {
19241924
ERR_THREAD_GUARD_V(0);
1925-
_update_children_cache();
1926-
19271925
if (p_include_internal) {
1928-
return data.children_cache.size();
1929-
} else {
1930-
return data.children_cache.size() - data.internal_children_front_count_cache - data.internal_children_back_count_cache;
1926+
return data.children.size();
19311927
}
1928+
1929+
_update_children_cache();
1930+
return data.children_cache.size() - data.internal_children_front_count_cache - data.internal_children_back_count_cache;
19321931
}
19331932

19341933
Node *Node::get_child(int p_index, bool p_include_internal) const {

0 commit comments

Comments
 (0)