If you are using GCC and working with code where one branch is very likely than the other, the builtin
__builtin_expect can be very handy.
As is often the case with optimizations, the effects can be counter productive when applied without profiling and confirming the expectation.
A safe version of this is defined as a macro in folly . It is a no-op when the builtin is not supported. This builtin is also often used in the linux kernel source