From 0d25ae0e081639375a7cb8ee76fccfd280520f5b Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Tue, 9 Jul 2019 13:20:53 +0200 Subject: [PATCH] Quality: Prefer BOOST_{,UN}LIKELY gcc optimizer macros over our own Our macro collides with Boost::DateTime and the gregorian classes and I don't see any reason why we shouldn't use Boost::Config being already there. --- lib/base/i2-base.hpp | 8 -------- lib/config/vmops.hpp | 4 ++-- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/base/i2-base.hpp b/lib/base/i2-base.hpp index 6bb756338..58aac4803 100644 --- a/lib/base/i2-base.hpp +++ b/lib/base/i2-base.hpp @@ -72,14 +72,6 @@ # pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif -#if defined(__GNUC__) -# define likely(x) __builtin_expect(!!(x), 1) -# define unlikely(x) __builtin_expect(!!(x), 0) -#else -# define likely(x) (x) -# define unlikely(x) (x) -#endif - #define BOOST_BIND_NO_PLACEHOLDERS #include diff --git a/lib/config/vmops.hpp b/lib/config/vmops.hpp index 72d820dfb..8bd456d40 100644 --- a/lib/config/vmops.hpp +++ b/lib/config/vmops.hpp @@ -235,10 +235,10 @@ public: static inline Value GetField(const Value& context, const String& field, bool sandboxed = false, const DebugInfo& debugInfo = DebugInfo()) { - if (unlikely(context.IsEmpty() && !context.IsString())) + if (BOOST_UNLIKELY(context.IsEmpty() && !context.IsString())) return Empty; - if (unlikely(!context.IsObject())) + if (BOOST_UNLIKELY(!context.IsObject())) return GetPrototypeField(context, field, true, debugInfo); Object::Ptr object = context; -- 2.50.1