added comments

This commit is contained in:
CPunch 2020-11-17 14:39:02 -06:00
parent c1854bdcf1
commit e6a377dfd0

View File

@ -109,13 +109,13 @@ static CTableEntry *findEntry(CTableEntry *entries, int mask, CValue key) {
static void resizeTbl(CState *state, CTable *tbl, size_t newCapacity) {
size_t size = sizeof(CTableEntry) * newCapacity;
cosmoM_checkGarbage(state, size);
cosmoM_checkGarbage(state, size); // if this allocation would cause a GC, run the GC
// if count > 8 and active entries < tombstones
if (tbl->count > MIN_TABLE_CAPACITY && tbl->count - tbl->tombstones < tbl->tombstones) {
int tombs = tbl->tombstones;
tbl->tombstones = 0; // set this to 0 so in our recursive call to resizeTbl() this branch isn't run again
resizeTbl(state, tbl, nextPow2((tbl->count - tombs)) * GROW_FACTOR);
resizeTbl(state, tbl, nextPow2((tbl->count - tombs) * GROW_FACTOR)); // shrink based on active entries to the next pow of 2
cosmoM_updateThreshhold(state); // force a threshhold update since this *could* be such a huge memory difference
return;
}