mirror of
https://github.com/CPunch/Cosmo.git
synced 2024-11-22 07:20:05 +00:00
added comments
This commit is contained in:
parent
c1854bdcf1
commit
e6a377dfd0
@ -109,13 +109,13 @@ static CTableEntry *findEntry(CTableEntry *entries, int mask, CValue key) {
|
|||||||
|
|
||||||
static void resizeTbl(CState *state, CTable *tbl, size_t newCapacity) {
|
static void resizeTbl(CState *state, CTable *tbl, size_t newCapacity) {
|
||||||
size_t size = sizeof(CTableEntry) * 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 count > 8 and active entries < tombstones
|
||||||
if (tbl->count > MIN_TABLE_CAPACITY && tbl->count - tbl->tombstones < tbl->tombstones) {
|
if (tbl->count > MIN_TABLE_CAPACITY && tbl->count - tbl->tombstones < tbl->tombstones) {
|
||||||
int tombs = 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
|
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
|
cosmoM_updateThreshhold(state); // force a threshhold update since this *could* be such a huge memory difference
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user