diff --git a/mm/mm_heap/mm_size2ndx.c b/mm/mm_heap/mm_size2ndx.c index 5d0f9fa2a7..73dad34cc5 100644 --- a/mm/mm_heap/mm_size2ndx.c +++ b/mm/mm_heap/mm_size2ndx.c @@ -24,6 +24,8 @@ #include +#include + #include #include "mm_heap/mm.h" @@ -42,19 +44,11 @@ int mm_size2ndx(size_t size) { - int ndx = 0; - if (size >= MM_MAX_CHUNK) { return MM_NNODES - 1; } size >>= MM_MIN_SHIFT; - while (size > 1) - { - ndx++; - size >>= 1; - } - - return ndx; + return flsl(size) - 1; }