C/C++ most efficient if statement evaluation
-
30-10-2019 - |
Question
X is true nearly 99.9% of the time but I need to handle Y and Z as well. Although the body of the X condition is empty, I'm thinking it should be faster than potentially checking 2 other conditions Y and Z if the X condition is omitted. What do you think?
if (likely(X))
{
}
else if (unlikely(Y))
{
...
}
else if (unlikely(Z))
{
...
}
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow