From d3473b2a951f41c80c0eb65a193224bb3a0b154e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20T=2E=20Listwon?= Date: Wed, 19 Jan 2022 11:33:27 +0100 Subject: [PATCH] Rework Node::get_node to omit is_absolute() check in best case scenario (cherry picked from commit e2792cc71caa89997c0127abd5bb4b0e19d67f46) --- scene/main/node.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 675294af7577..9df729c75183 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1303,12 +1303,14 @@ Node *Node::get_node_or_null(const NodePath &p_path) const { Node *Node::get_node(const NodePath &p_path) const { Node *node = get_node_or_null(p_path); - if (p_path.is_absolute()) { - ERR_FAIL_COND_V_MSG(!node, nullptr, - vformat("(Node not found: \"%s\" (absolute path attempted from \"%s\").)", p_path, get_path())); - } else { - ERR_FAIL_COND_V_MSG(!node, nullptr, - vformat("(Node not found: \"%s\" (relative to \"%s\").)", p_path, get_path())); + if (unlikely(!node)) { + if (p_path.is_absolute()) { + ERR_FAIL_V_MSG(nullptr, + vformat("(Node not found: \"%s\" (absolute path attempted from \"%s\").)", p_path, get_path())); + } else { + ERR_FAIL_V_MSG(nullptr, + vformat("(Node not found: \"%s\" (relative to \"%s\").)", p_path, get_path())); + } } return node;