perf(hash table): made shrink to fit skip capacity calculation if size is 0
This commit is contained in:
parent
40ebfe95cf
commit
c36696255d
1 changed files with 3 additions and 2 deletions
|
|
@ -216,9 +216,10 @@ FledastyError fledasty_hash_table_shrink_to_fit(FledastyHashTable *current_hash_
|
|||
const size_t old_capacity = current_hash_table->capacity;
|
||||
FledastyDynamicArray *previous_table = current_hash_table->Table;
|
||||
|
||||
current_hash_table->capacity = (current_hash_table->size * 100) / FLEDASTY_HASH_TABLE_SIZE_THRESHOLD;
|
||||
if (current_hash_table->capacity == 0) {
|
||||
if (current_hash_table->size == 0) {
|
||||
current_hash_table->capacity = 1024;
|
||||
} else {
|
||||
current_hash_table->capacity = (current_hash_table->size * 100) / FLEDASTY_HASH_TABLE_SIZE_THRESHOLD;
|
||||
}
|
||||
|
||||
current_hash_table->Table = (FledastyDynamicArray*)hallocy_calloc(sizeof(FledastyDynamicArray), current_hash_table->capacity);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue