From 7f36bb684659b026268d3f889fec2ed4c80e89dc Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 13 Oct 2017 20:24:11 +0200 Subject: [PATCH] Mark unlikely code path. It also changes MSVC behavior from generating two jumps to just one. --- client/concurrentqueue.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/client/concurrentqueue.h b/client/concurrentqueue.h index 93d5abe2..bc19c492 100644 --- a/client/concurrentqueue.h +++ b/client/concurrentqueue.h @@ -1970,13 +1970,10 @@ private: tracy_force_inline T* enqueue_begin(index_t& currentTailIndex) { currentTailIndex = this->tailIndex.load(std::memory_order_relaxed); - if ((currentTailIndex & static_cast(BLOCK_SIZE - 1)) != 0) { - return (*this->tailBlock)[currentTailIndex]; - } - else { + if (details::unlikely((currentTailIndex & static_cast(BLOCK_SIZE - 1)) == 0)) { this->enqueue_begin_alloc(currentTailIndex); - return (*this->tailBlock)[currentTailIndex]; } + return (*this->tailBlock)[currentTailIndex]; } tracy_force_inline std::atomic& get_tail_index()