From 53e9d908506dc0edc5dcf149da6bddd0a64df4c5 Mon Sep 17 00:00:00 2001 From: CrazyRoka Date: Thu, 11 Jul 2024 20:40:00 +0100 Subject: [PATCH 1/2] Optimize Node::is_readable_from_caller_thread() by prioritizing the most common case. --- scene/main/node.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scene/main/node.h b/scene/main/node.h index 6b93724478..d347bda552 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -596,7 +596,7 @@ public: // No thread processing. // Only accessible if node is outside the scene tree // or access will happen from a node-safe thread. - return !data.inside_tree || is_current_thread_safe_for_nodes(); + return is_current_thread_safe_for_nodes() || !data.inside_tree; } else { // Thread processing. return true; From 6c86268fdd8aa5fac6891a6c6f344d22518d2d96 Mon Sep 17 00:00:00 2001 From: CrazyRoka Date: Fri, 12 Jul 2024 13:38:41 +0100 Subject: [PATCH 2/2] Decorate rare !data.inside_tree condition with unlikely --- scene/main/node.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scene/main/node.h b/scene/main/node.h index d347bda552..ee195ddef9 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -596,7 +596,7 @@ public: // No thread processing. // Only accessible if node is outside the scene tree // or access will happen from a node-safe thread. - return is_current_thread_safe_for_nodes() || !data.inside_tree; + return is_current_thread_safe_for_nodes() || unlikely(!data.inside_tree); } else { // Thread processing. return true;