9 static const size_t kSizeAnchors[] = {
12 250000, 500000, 750000, 1000000
15 #define TOTAL_SIZE_ANCHORS (sizeof(kSizeAnchors) / sizeof(size_t))
18 static size_t bucket_for_size(
size_t size)
46 static size_t signed_abs(
size_t lhs,
size_t rhs)
55 static size_t nearest_const(
size_t size)
58 size_t distance = SIZE_MAX;
62 size_t d = signed_abs(
size, kSizeAnchors[i]);
66 num = kSizeAnchors[i];
77 static size_t select_best_size(
size_t size)
79 size_t near = nearest_const(
size);
80 size_t bucket = bucket_for_size(near);
87 size_t bucket = select_best_size(
size);
88 return map_new(bucket, info, arena);
#define STA_DECL
sal2 annotation on function implementations to copy annotations from the declaration
STA_DECL map_t * map_optimal(size_t size, hash_info_t info, arena_t *arena)
create a new map with an optimal size
CT_NODISCARD CT_STD_API map_t * map_new(size_t size, hash_info_t info, arena_t *arena)
create a new map on the heap
#define TOTAL_SIZE_ANCHORS
information for using a type in a hashset or hashmap