diff --git a/misc.h b/misc.h index 7a9cbd68..24e441e7 100644 --- a/misc.h +++ b/misc.h @@ -114,6 +114,18 @@ NAMESPACE_BEGIN(CryptoPP) // Forward declaration for IntToString specialization class Integer; +// ************** branch prediction *************** + +// Micro-optimization, use juditiously. Be sure you find a hotspot +// using 'make coverage', and its in a tight loop. Otherwise, DFW. +#if defined(__GNUC__) +# define CRYPTOPP_LIKELY(x) __builtin_expect(!!(x), 1) +# define CRYPTOPP_UNLIKELY(x) __builtin_expect(!!(x), 0) +#else +# define CRYPTOPP_LIKELY(x) (x) +# define CRYPTOPP_UNLIKELY(x) (x) +#endif + // ************** compile-time assertion *************** #if CRYPTOPP_DOXYGEN_PROCESSING