perf(hash table): made shrink to fit skip capacity calculation if size is 0

This commit is contained in:
Mineplay 2025-05-28 03:54:30 -05:00
parent 40ebfe95cf
commit c36696255d

View file

@ -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);