Added some constexpr to some ifs.

This commit is contained in:
Matthew Parkinson
2019-02-15 16:12:38 +00:00
parent ac8e5e4e5b
commit 8698f87018
6 changed files with 13 additions and 13 deletions

View File

@@ -943,7 +943,7 @@ namespace snmalloc
{
super_available.remove(super);
if (decommit_strategy == DecommitSuper)
if constexpr (decommit_strategy == DecommitSuper)
{
large_allocator.memory_provider.notify_not_using(
(void*)((size_t)super + OS_PAGE_SIZE),
@@ -1027,7 +1027,7 @@ namespace snmalloc
sc->remove(slab);
}
if (decommit_strategy == DecommitSuper)
if constexpr (decommit_strategy == DecommitSuper)
{
large_allocator.memory_provider.notify_not_using(
(void*)((size_t)slab + OS_PAGE_SIZE),

View File

@@ -193,7 +193,7 @@ namespace snmalloc
{
// The first page is already in "use" for the stack element,
// this will need zeroing for a YesZero call.
if (zero_mem == YesZero)
if constexpr (zero_mem == YesZero)
memory_provider.template zero<true>(p, OS_PAGE_SIZE);
// Notify we are using the rest of the allocation.
@@ -205,7 +205,7 @@ namespace snmalloc
else
{
// This is a superslab that has not been decommitted.
if (zero_mem == YesZero)
if constexpr (zero_mem == YesZero)
memory_provider.template zero<true>(
p, bits::align_up(size, OS_PAGE_SIZE));
}

View File

@@ -86,9 +86,9 @@ namespace snmalloc
assert(bits::is_aligned_block<OS_PAGE_SIZE>(p, OS_PAGE_SIZE));
size = bits::align_up(size, OS_PAGE_SIZE);
if (decommit_strategy == DecommitAll)
if constexpr (decommit_strategy == DecommitAll)
memory_provider.template notify_using<zero_mem>(p, size);
else if (zero_mem == YesZero)
else if constexpr (zero_mem == YesZero)
memory_provider.template zero<true>(p, size);
return p;
@@ -104,7 +104,7 @@ namespace snmalloc
free++;
stack[--head] = pointer_to_index(p);
if (decommit_strategy == DecommitAll)
if constexpr (decommit_strategy == DecommitAll)
memory_provider.notify_not_using(p, sizeclass_to_size(sizeclass));
return was_full;

View File

@@ -169,7 +169,7 @@ namespace snmalloc
meta[0].sizeclass = sizeclass;
meta[0].link = SLABLINK_INDEX;
if (decommit_strategy == DecommitAll)
if constexpr (decommit_strategy == DecommitAll)
{
memory_provider.template notify_using<NoZero>(
(void*)((size_t)this + OS_PAGE_SIZE), SLAB_SIZE - OS_PAGE_SIZE);
@@ -194,7 +194,7 @@ namespace snmalloc
head = h + n + 1;
used += 2;
if (decommit_strategy == DecommitAll)
if constexpr (decommit_strategy == DecommitAll)
{
memory_provider.template notify_using<NoZero>(slab, SLAB_SIZE);
}
@@ -216,7 +216,7 @@ namespace snmalloc
bool was_almost_full = is_almost_full();
used -= 2;
if (decommit_strategy == DecommitAll)
if constexpr (decommit_strategy == DecommitAll)
memory_provider.notify_not_using(slab, SLAB_SIZE);
assert(meta[index].is_unused());
@@ -231,7 +231,7 @@ namespace snmalloc
Action dealloc_short_slab(MemoryProvider& memory_provider)
{
// This is the short slab.
if (decommit_strategy == DecommitAll)
if constexpr (decommit_strategy == DecommitAll)
{
memory_provider.notify_not_using(
(void*)((size_t)this + OS_PAGE_SIZE), SLAB_SIZE - OS_PAGE_SIZE);

View File

@@ -33,7 +33,7 @@ namespace snmalloc
{
assert(
bits::is_aligned_block<OS_PAGE_SIZE>(p, size) || (zero_mem == NoZero));
if (zero_mem == YesZero)
if constexpr (zero_mem == YesZero)
zero(p, size);
}

View File

@@ -36,7 +36,7 @@ namespace snmalloc
assert(
bits::is_aligned_block<OS_PAGE_SIZE>(p, size) || (zero_mem == NoZero));
if (zero_mem == YesZero)
if constexpr (zero_mem == YesZero)
zero<true>(p, size);
}