Remove all instances of static_cast<size_t>(1).

In preparation for removing magic numbers, simplify code that is
computing masks with a single bit set.
This commit is contained in:
David Chisnall
2019-04-30 11:49:00 +01:00
parent 95c23b1a00
commit 8bd136c224
7 changed files with 32 additions and 23 deletions

View File

@@ -98,8 +98,7 @@ namespace snmalloc
{
break;
}
size_t rsize = (static_cast<size_t>(1) << SUPERSLAB_BITS)
<< large_class;
size_t rsize = bits::one_at_bit(SUPERSLAB_BITS) << large_class;
size_t decommit_size = rsize - OS_PAGE_SIZE;
// Grab all of the chunks of this size class.
auto* slab = large_stack[large_class].pop_all();
@@ -321,7 +320,7 @@ namespace snmalloc
template<ZeroMem zero_mem = NoZero, AllowReserve allow_reserve = YesReserve>
void* alloc(size_t large_class, size_t size)
{
size_t rsize = (static_cast<size_t>(1) << SUPERSLAB_BITS) << large_class;
size_t rsize = bits::one_at_bit(SUPERSLAB_BITS) << large_class;
if (size == 0)
size = rsize;