fast_allocator.c: optimize for the region with single allocator

pull/37/merge
YuQing 2021-09-14 08:28:03 +08:00
parent 55f1e139a9
commit 8717f85608
2 changed files with 10 additions and 1 deletions

View File

@ -167,6 +167,15 @@ static int region_init(struct fast_allocator_context *acontext,
return result;
}
if (region->count == 1) {
if (region->start == 0) {
region->step += sizeof(struct allocator_wrapper);
} else {
region->start += sizeof(struct allocator_wrapper);
}
region->end += sizeof(struct allocator_wrapper);
}
name = name_buff;
result = 0;
allocator = region->allocators;

View File

@ -26,7 +26,7 @@
#include "fastcommon/array_allocator.h"
#include "fastcommon/sorted_array.h"
#define ELEMENT_COUNT 5 * 1000
#define ELEMENT_COUNT 1000
static bool silence;