Skip to content

Commit a377f50

Browse files
committed
Merge pull request #106226 from lawnjelly/faster_get_child_count
Faster `Node::get_child_count()`
2 parents 599a956 + 795ed8f commit a377f50

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)