1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-12 13:20:55 +00:00

Rework Node::get_node to omit is_absolute() check in best case scenario

(cherry picked from commit e2792cc71c)
This commit is contained in:
Bartłomiej T. Listwon
2022-01-19 11:33:27 +01:00
committed by Rémi Verschelde
parent 96a325dec8
commit d3473b2a95

View File

@@ -1303,13 +1303,15 @@ Node *Node::get_node_or_null(const NodePath &p_path) const {
Node *Node::get_node(const NodePath &p_path) const { Node *Node::get_node(const NodePath &p_path) const {
Node *node = get_node_or_null(p_path); Node *node = get_node_or_null(p_path);
if (unlikely(!node)) {
if (p_path.is_absolute()) { if (p_path.is_absolute()) {
ERR_FAIL_COND_V_MSG(!node, nullptr, ERR_FAIL_V_MSG(nullptr,
vformat("(Node not found: \"%s\" (absolute path attempted from \"%s\").)", p_path, get_path())); vformat("(Node not found: \"%s\" (absolute path attempted from \"%s\").)", p_path, get_path()));
} else { } else {
ERR_FAIL_COND_V_MSG(!node, nullptr, ERR_FAIL_V_MSG(nullptr,
vformat("(Node not found: \"%s\" (relative to \"%s\").)", p_path, get_path())); vformat("(Node not found: \"%s\" (relative to \"%s\").)", p_path, get_path()));
} }
}
return node; return node;
} }