Browse Source

Merge pull request #107544 from lawnjelly/node_children_localvector

[3.x] Change `Node` children to use `LocalVector`
lawnjelly 2 months ago
parent
commit
6645716e32
2 changed files with 4 additions and 4 deletions
  1. 3 3
      scene/main/node.cpp
  2. 1 1
      scene/main/node.h

+ 3 - 3
scene/main/node.cpp

@@ -1156,7 +1156,7 @@ void Node::_validate_child_name(Node *p_child, bool p_force_human_readable) {
 			unique = false;
 		} else {
 			//check if exists
-			Node **children = data.children.ptrw();
+			Node **children = data.children.ptr();
 			int cc = data.children.size();
 
 			for (int i = 0; i < cc; i++) {
@@ -1346,7 +1346,7 @@ void Node::remove_child(Node *p_child) {
 	ERR_FAIL_COND_MSG(data.blocked > 0, "Parent node is busy setting up children, remove_node() failed. Consider using call_deferred(\"remove_child\", child) instead.");
 
 	int child_count = data.children.size();
-	Node **children = data.children.ptrw();
+	Node **children = data.children.ptr();
 	int idx = -1;
 
 	if (p_child->data.pos >= 0 && p_child->data.pos < child_count) {
@@ -1379,7 +1379,7 @@ void Node::remove_child(Node *p_child) {
 
 	//update pointer and size
 	child_count = data.children.size();
-	children = data.children.ptrw();
+	children = data.children.ptr();
 
 	for (int i = idx; i < child_count; i++) {
 		children[i]->data.pos = i;

+ 1 - 1
scene/main/node.h

@@ -107,7 +107,7 @@ private:
 
 		Node *parent;
 		Node *owner;
-		Vector<Node *> children; // list of children
+		LocalVectori<Node *> children; // list of children
 		HashMap<StringName, Node *> owned_unique_nodes;
 		bool unique_name_in_owner = false;