Skip to content

Commit b50ce59

Browse files
Optimize initial Node::get_path call by avoiding Vector::reverse
1 parent 8d8041b commit b50ce59

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
@@ -2396,14 +2396,14 @@ NodePath Node::get_path() const {
23962396
const Node *n = this;
23972397

23982398
Vector<StringName> path;
2399+
path.resize(data.depth);
23992400

2401+
StringName *ptrw = path.ptrw();
24002402
while (n) {
2401-
path.push_back(n->get_name());
2403+
ptrw[n->data.depth - 1] = n->get_name();
24022404
n = n->data.parent;
24032405
}
24042406

2405-
path.reverse();
2406-
24072407
data.path_cache = memnew(NodePath(path, true));
24082408

24092409
return *data.path_cache;

0 commit comments

Comments
 (0)