optimize size calculation for 16 byte spaced sizes

pull/50/head
Daniel Micay 2018-09-11 14:44:15 -04:00
parent 2d6ad18aa4
commit 7a404ddbf2
1 changed files with 4 additions and 1 deletions

View File

@ -85,7 +85,10 @@ static inline struct size_info get_size_info(size_t size) {
if (size == 0) {
return (struct size_info){16, 0};
}
for (unsigned class = 1; class < N_SIZE_CLASSES; class++) {
if (size <= 128) {
return (struct size_info){(size + 15) & ~15, ((size - 1) >> 4) + 1};
}
for (unsigned class = 9; class < N_SIZE_CLASSES; class++) {
size_t real_size = size_classes[class];
if (size <= real_size) {
return (struct size_info){real_size, class};