Added branch predictor hint.

This commit is contained in:
Matthew Parkinson
2019-05-13 14:29:02 +01:00
committed by Matthew Parkinson
parent 5d711a2e65
commit b484619f20
2 changed files with 5 additions and 1 deletions

View File

@@ -9,7 +9,11 @@
# define ALWAYSINLINE __forceinline
# define NOINLINE __declspec(noinline)
# define HEADER_GLOBAL __declspec(selectany)
# define likely(x) !!(x)
# define unlikely(x) !!(x)
#else
# define likely(x) __builtin_expect(!!(x), 1)
# define unlikely(x) __builtin_expect(!!(x), 0)
# include <cpuid.h>
# include <emmintrin.h>
# define ALWAYSINLINE __attribute__((always_inline))

View File

@@ -872,7 +872,7 @@ namespace snmalloc
inline void handle_message_queue()
{
// Inline the empty check, but not necessarily the full queue handling.
if (message_queue().is_empty())
if (likely(message_queue().is_empty()))
return;
handle_message_queue_inner();