put likely/unlikely in scope (#420)

* put likely/unlikely in scope

Signed-off-by: SchrodingerZhu <i@zhuyi.fan>

* make clang-format happy

Signed-off-by: SchrodingerZhu <i@zhuyi.fan>
This commit is contained in:
Schrodinger ZHU Yifan
2021-11-18 00:05:52 +08:00
committed by GitHub
parent cd0311b26f
commit faa80037bb
11 changed files with 36 additions and 33 deletions

View File

@@ -136,7 +136,7 @@ namespace
auto& alloc = ThreadAlloc::get();
void* p = const_cast<void*>(ptr);
if (unlikely(alloc.remaining_bytes(ptr) < len))
if (SNMALLOC_UNLIKELY(alloc.remaining_bytes(ptr) < len))
{
if constexpr (FailFast)
{
@@ -209,7 +209,7 @@ extern "C"
// 0 is a very common size for memcpy and we don't need to do external
// pointer checks if we hit it. It's also the fastest case, to encourage
// the compiler to favour the other cases.
if (unlikely(len == 0))
if (SNMALLOC_UNLIKELY(len == 0))
{
return dst;
}