Optimize initial Node::get_path call by avoiding Vector::reverse

This commit is contained in:
HolonProduction 2025-10-01 19:15:39 +02:00
parent 8d8041bd4d
commit b50ce590b4

View file

@ -2396,14 +2396,14 @@ NodePath Node::get_path() const {
const Node *n = this;
Vector<StringName> path;
path.resize(data.depth);
StringName *ptrw = path.ptrw();
while (n) {
path.push_back(n->get_name());
ptrw[n->data.depth - 1] = n->get_name();
n = n->data.parent;
}
path.reverse();
data.path_cache = memnew(NodePath(path, true));
return *data.path_cache;