diff --git a/include/xemmai/heap.h b/include/xemmai/heap.h index c0a9044..9e84c46 100644 --- a/include/xemmai/heap.h +++ b/include/xemmai/heap.h @@ -16,10 +16,6 @@ namespace xemmai template class t_heap { - static constexpr size_t f_log(size_t a_x) - { - return a_x > 1 ? f_log(a_x >> 1) + 1 : 0; - } static void* f_map(size_t a_n) { #ifdef __unix__ @@ -139,10 +135,10 @@ class t_heap constexpr T* f_allocate_medium(size_t a_size); public: - static constexpr size_t V_UNIT = 2 << f_log(sizeof(T) - 1); + static constexpr size_t V_UNIT = std::bit_ceil(sizeof(T)); static_assert(V_UNIT >> 1 < sizeof(T)); static_assert(V_UNIT >= sizeof(T)); - static constexpr size_t V_RANKX = sizeof(void*) * 8 - f_log(V_UNIT); + static constexpr size_t V_RANKX = std::countl_zero(V_UNIT - 1); static_assert((V_UNIT << (V_RANKX - 1)) - 1 == ~size_t(0) >> 1); static_assert((V_UNIT << V_RANKX) - 1 == ~size_t(0));