More performant OP_GETOBJECT & OP_SETOBJECT

constant indexes are now embedded in the instruction
This commit is contained in:
2021-01-07 17:19:17 -06:00
parent ea4654cb6e
commit c5bd0c2478
5 changed files with 26 additions and 24 deletions

View File

@@ -185,14 +185,16 @@ COSMO_API CValue* cosmoT_insert(CState *state, CTable *tbl, CValue key) {
}
bool cosmoT_get(CTable *tbl, CValue key, CValue *val) {
// sanity check
if (tbl->count == 0) {
*val = cosmoV_newNil();
return false; // sanity check
return false;
}
CTableEntry *entry = findEntry(tbl->table, tbl->capacity - 1, key);
*val = entry->val;
// return if get was successful
return !(IS_NIL(entry->key));
}