diff options
author | Chris Robinson <[email protected]> | 2019-08-04 11:59:14 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-08-04 11:59:14 -0700 |
commit | 2fa2c35bdc2a09d5e856bb12ad6dff556bbe65a8 (patch) | |
tree | 4a6c7a5f2a80ad7870e9028e48b8b99e558042f5 /common | |
parent | 7897de31d0f75f4ac1d91fe8c470953e9f54d151 (diff) |
Modify LIKELY and UNLIKELY to not need extra parenthesis
Diffstat (limited to 'common')
-rw-r--r-- | common/alexcpt.cpp | 2 | ||||
-rw-r--r-- | common/alnumeric.h | 6 | ||||
-rw-r--r-- | common/intrusive_ptr.h | 2 | ||||
-rw-r--r-- | common/opthelpers.h | 4 |
4 files changed, 7 insertions, 7 deletions
diff --git a/common/alexcpt.cpp b/common/alexcpt.cpp index 9e04bbaf..5055e34f 100644 --- a/common/alexcpt.cpp +++ b/common/alexcpt.cpp @@ -17,7 +17,7 @@ backend_exception::backend_exception(ALCenum code, const char *msg, ...) : mErro va_start(args, msg); va_copy(args2, args); int msglen{std::vsnprintf(nullptr, 0, msg, args)}; - if(LIKELY(msglen > 0)) + if LIKELY(msglen > 0) { mMessage.resize(static_cast<size_t>(msglen)+1); std::vsnprintf(&mMessage[0], mMessage.length(), msg, args2); diff --git a/common/alnumeric.h b/common/alnumeric.h index 950eebe1..7035715c 100644 --- a/common/alnumeric.h +++ b/common/alnumeric.h @@ -246,11 +246,11 @@ inline int float2int(float f) noexcept shift = ((conv.i>>23)&0xff) - (127+23); /* Over/underflow */ - if(UNLIKELY(shift >= 31 || shift < -23)) + if UNLIKELY(shift >= 31 || shift < -23) return 0; mant = (conv.i&0x7fffff) | 0x800000; - if(LIKELY(shift < 0)) + if LIKELY(shift < 0) return (mant >> -shift) * sign; return (mant << shift) * sign; @@ -293,7 +293,7 @@ inline float fast_roundf(float f) noexcept sign = (conv.i>>31)&0x01; expo = (conv.i>>23)&0xff; - if(UNLIKELY(expo >= 150/*+23*/)) + if UNLIKELY(expo >= 150/*+23*/) { /* An exponent (base-2) of 23 or higher is incapable of sub-integral * precision, so it's already an integral value. We don't need to worry diff --git a/common/intrusive_ptr.h b/common/intrusive_ptr.h index 831b8302..fa76ad48 100644 --- a/common/intrusive_ptr.h +++ b/common/intrusive_ptr.h @@ -16,7 +16,7 @@ public: unsigned int release() noexcept { auto ref = DecrementRef(mRef); - if(UNLIKELY(ref == 0)) + if UNLIKELY(ref == 0) delete static_cast<T*>(this); return ref; } diff --git a/common/opthelpers.h b/common/opthelpers.h index c83229f5..58578c15 100644 --- a/common/opthelpers.h +++ b/common/opthelpers.h @@ -12,9 +12,9 @@ * required to be true, but it can result in more optimal code for the true * path at the expense of a less optimal false path. */ -#define LIKELY(x) __builtin_expect(!!(x), !false) +#define LIKELY(x) (__builtin_expect(!!(x), !false)) /* The opposite of LIKELY, optimizing the case where the condition is false. */ -#define UNLIKELY(x) __builtin_expect(!!(x), false) +#define UNLIKELY(x) (__builtin_expect(!!(x), false)) /* Unlike LIKELY, ASSUME requires the condition to be true or else it invokes * undefined behavior. It's essentially an assert without actually checking the * condition at run-time, allowing for stronger optimizations than LIKELY. |