Update to use a more efficient power of 2 check. (#274)

This commit is contained in:
Matthew Parkinson
2021-01-27 11:58:41 +00:00
committed by GitHub
parent db3580a9d8
commit a3660c4069
10 changed files with 21 additions and 18 deletions

View File

@@ -175,7 +175,7 @@ namespace snmalloc
template<bool committed>
void* reserve(size_t size)
{
SNMALLOC_ASSERT(bits::next_pow2(size) == size);
SNMALLOC_ASSERT(bits::is_pow2(size));
SNMALLOC_ASSERT(size >= sizeof(void*));
if constexpr (pal_supports<AlignedAllocation, PAL>)

View File

@@ -183,7 +183,7 @@ namespace snmalloc
// Client responsible for checking alignment is not zero
SNMALLOC_ASSERT(alignment != 0);
// Client responsible for checking alignment is a power of two
SNMALLOC_ASSERT(bits::next_pow2(alignment) == alignment);
SNMALLOC_ASSERT(bits::is_pow2(alignment));
return ((alignment - 1) | (size - 1)) + 1;
}