diff --git a/src/ds/helpers.h b/src/ds/helpers.h index e94227d..fdae63f 100644 --- a/src/ds/helpers.h +++ b/src/ds/helpers.h @@ -27,7 +27,7 @@ namespace snmalloc // If defined should be initially false; assert(first == nullptr || *first == false); - if (!initialised.load(std::memory_order_acquire)) + if (unlikely(!initialised.load(std::memory_order_acquire))) { FlagLock lock(flag); if (!initialised) diff --git a/src/mem/threadalloc.h b/src/mem/threadalloc.h index 59a05e3..98f8096 100644 --- a/src/mem/threadalloc.h +++ b/src/mem/threadalloc.h @@ -284,7 +284,7 @@ namespace snmalloc { Alloc*& per_thread = inner_get(); - if (per_thread != nullptr) + if (likely(per_thread != nullptr)) return per_thread; // Slow path that performs initialization