From b50ce590b4d4a5c0a423293311ebcf38a0cb27a5 Mon Sep 17 00:00:00 2001 From: HolonProduction Date: Wed, 1 Oct 2025 19:15:39 +0200 Subject: [PATCH] Optimize initial `Node::get_path` call by avoiding `Vector::reverse` --- scene/main/node.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 9fe529155e..79982552cf 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -2396,14 +2396,14 @@ NodePath Node::get_path() const { const Node *n = this; Vector 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;