summaryrefslogtreecommitdiff
path: root/core/variant.cpp
diff options
context:
space:
mode:
authorHein-Pieter van Braam <hp@tmm.cx>2017-09-20 11:04:50 +0200
committerHein-Pieter van Braam <hp@tmm.cx>2017-09-21 18:28:28 +0200
commit22358babda1452ee6db4d662dff373472b93fdc6 (patch)
treef47c0c224ef12098147a3e289de7410758043fc2 /core/variant.cpp
parent4664d03a0e39be6dc8f5ba8154e1d6b776fa2293 (diff)
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.
Diffstat (limited to 'core/variant.cpp')
-rw-r--r--core/variant.cpp4
1 files changed, 2 insertions, 2 deletions
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<Color> &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;
}