Skip to content

Commit 7bdec67

Browse files
committed
Merge pull request #111126 from HolonProduction/gotta-get-path
Optimize initial `Node::get_path` call by avoiding `Vector::reverse`
2 parents f44aa13 + b50ce59 commit 7bdec67

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

scene/main/node.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,14 +2416,14 @@ NodePath Node::get_path() const {
24162416
const Node *n = this;
24172417

24182418
Vector<StringName> path;
2419+
path.resize(data.depth);
24192420

2421+
StringName *ptrw = path.ptrw();
24202422
while (n) {
2421-
path.push_back(n->get_name());
2423+
ptrw[n->data.depth - 1] = n->get_name();
24222424
n = n->data.parent;
24232425
}
24242426

2425-
path.reverse();
2426-
24272427
data.path_cache = memnew(NodePath(path, true));
24282428

24292429
return *data.path_cache;

0 commit comments

Comments
 (0)