YOU CAN DO IT EXACTLY HOW YOU DO IT!!!!!!!!

This commit is contained in:
2026-07-01 20:52:28 +03:00
parent 404332fcba
commit 583b554534
10 changed files with 845 additions and 387 deletions

View File

@@ -216,7 +216,7 @@ noomV_Table* noomV_allocTable(noom_LuaVM* vm, noom_uint_t arraylen, noom_uint_t
if (t->entrydata == 0) return 0;
t->entries = cap;
for (size_t i = 0; i < cap * 2; i++) {
t->entrydata[i] = noomV_nil;
t->entrydata[i].tag = NOOMV_VNIL;
}
return t;
}
@@ -352,20 +352,10 @@ noom_Exit noomV_rawsetTable(noom_LuaVM* vm, noomV_Table* t, noomV_Value key, noo
val.autoclose = 0;
noom_uint_t hash = noomV_rawhashValue(key);
noom_uint_t idx = hash % t->entries;
noom_uint_t count = 0;
noomV_Value *freshTomb = 0;
while (count < t->entries) {
while (1) {
noomV_Value key2 = t->entrydata[idx];
// tombstone, for creation!
if(key2.isptr) {
freshTomb = t->entrydata + idx;
idx++;
idx %= t->entries;
count++;
continue;
}
// unallocated!
if (key2.tag == NOOMV_VNIL) {
// tombstone!
if (key2.isptr) {
t->entrydata[idx] = key;
t->entrydata[idx + t->entries] = val;
return NOOM_OK;
@@ -377,11 +367,7 @@ noom_Exit noomV_rawsetTable(noom_LuaVM* vm, noomV_Table* t, noomV_Value key, noo
}
idx++;
idx %= t->entries;
count++;
}
if(freshTomb == 0) return NOOM_ENOMEM;
freshTomb[0] = key;
freshTomb[t->entries] = val;
return NOOM_OK;
}