Skip to content

Commit

Permalink
Rework Node::get_node to omit is_absolute() check in best case scenario
Browse files Browse the repository at this point in the history
(cherry picked from commit e2792cc)
  • Loading branch information
Listwon authored and akien-mga committed Jan 25, 2022
1 parent 96a325d commit d3473b2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions scene/main/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d3473b2

Please sign in to comment.