MCPcopy Index your code
hub / github.com/git/git / alloc_table

Function alloc_table

hashmap.c:76–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74#define HASHMAP_LOAD_FACTOR 80
75
76static void alloc_table(struct hashmap *map, unsigned int size)
77{
78 map->tablesize = size;
79 CALLOC_ARRAY(map->table, size);
80
81 /* calculate resize thresholds for new size */
82 map->grow_at = (unsigned int) ((uint64_t) size * HASHMAP_LOAD_FACTOR / 100);
83 if (size <= HASHMAP_INITIAL_SIZE)
84 map->shrink_at = 0;
85 else
86 /*
87 * The shrink-threshold must be slightly smaller than
88 * (grow-threshold / resize-factor) to prevent erratic resizing,
89 * thus we divide by (resize-factor + 1).
90 */
91 map->shrink_at = map->grow_at / ((1 << HASHMAP_RESIZE_BITS) + 1);
92}
93
94static inline int entry_equals(const struct hashmap *map,
95 const struct hashmap_entry *e1,

Callers 3

rehashFunction · 0.85
hashmap_initFunction · 0.85
hashmap_addFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected