File tree Expand file tree Collapse file tree 1 file changed +22
-6
lines changed
Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -1814,14 +1814,30 @@ Node *Node::get_child(int p_index, bool p_include_internal) const {
18141814
18151815TypedArray<Node> Node::get_children (bool p_include_internal) const {
18161816 ERR_THREAD_GUARD_V (TypedArray<Node>());
1817- TypedArray<Node> arr;
1818- int cc = get_child_count (p_include_internal);
1819- arr.resize (cc);
1820- for (int i = 0 ; i < cc; i++) {
1821- arr[i] = get_child (i, p_include_internal);
1817+ _update_children_cache ();
1818+
1819+ TypedArray<Node> children;
1820+
1821+ if (p_include_internal) {
1822+ children.resize (data.children_cache .size ());
1823+
1824+ Array::Iterator itr = children.begin ();
1825+ for (const Node *child : data.children_cache ) {
1826+ *itr = child;
1827+ ++itr;
1828+ }
1829+ } else {
1830+ const int size = data.children_cache .size () - data.internal_children_back_count_cache ;
1831+ children.resize (size - data.internal_children_front_count_cache );
1832+
1833+ Array::Iterator itr = children.begin ();
1834+ for (int i = data.internal_children_front_count_cache ; i < size; i++) {
1835+ *itr = data.children_cache [i];
1836+ ++itr;
1837+ }
18221838 }
18231839
1824- return arr ;
1840+ return children ;
18251841}
18261842
18271843Node *Node::_get_child_by_name (const StringName &p_name) const {
You can’t perform that action at this time.
0 commit comments