mirror of
https://github.com/CPunch/Cosmo.git
synced 2025-10-20 16:00:23 +00:00
More performant OP_GETOBJECT & OP_SETOBJECT
constant indexes are now embedded in the instruction
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user