From 22358babda1452ee6db4d662dff373472b93fdc6 Mon Sep 17 00:00:00 2001 From: Hein-Pieter van Braam Date: Wed, 20 Sep 2017 11:04:50 +0200 Subject: Implement Linux-style likely()/unlikely() macros This implement branch prediction macros likely() and unlikely() like in Linux. When using these macros please ensure that when you use them the condition in the branch really is very, very likely or unlikely. Think 90+% of the time. Primarily useful for error checking. (And I implement these macros for all our error checking macros now) See this article for more information: https://kernelnewbies.org/FAQ/LikelyUnlikely There are more places where these macros may make sense in renderer and physics engine. Placing them will come in another commit down the line. --- core/variant.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core/variant.cpp') diff --git a/core/variant.cpp b/core/variant.cpp index 52bdd4e22d..f70e4a5218 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -2469,10 +2469,10 @@ Variant::Variant(const Vector &p_array) { void Variant::operator=(const Variant &p_variant) { - if (this == &p_variant) + if (unlikely(this == &p_variant)) return; - if (type != p_variant.type) { + if (unlikely(type != p_variant.type)) { reference(p_variant); return; } -- cgit v1.2.3