Towards a new implementation of arrays
The array part of a table wastes too much space, due to padding. To avoid that, we need to store values in the array as something different from a TValue. Therefore, the API for table access should not assume that any value in a table lives in a *TValue. This commit is the first step to remove that assumption: functions luaH_get*, instead of returning a *TValue where the value lives, receive a *TValue where to put the value being accessed. (We still have to change the luaH_set* functions.)
This commit is contained in:
21
ltable.h
21
ltable.h
@@ -35,6 +35,27 @@
|
||||
#define nodefromval(v) cast(Node *, (v))
|
||||
|
||||
|
||||
/* results from get/set */
|
||||
#define HOK 0
|
||||
#define HNOTFOUND 1
|
||||
#define HNOTATABLE 2
|
||||
|
||||
|
||||
/* fast access to components of array values */
|
||||
#define getArrTag(t,k) (&(t)->array[k - 1].tt_)
|
||||
#define getArrVal(t,k) (&(t)->array[k - 1].value_)
|
||||
|
||||
#define tagisempty(tag) (novariant(tag) == LUA_TNIL)
|
||||
|
||||
#define arr2val(h,k,tag,res) \
|
||||
((res)->tt_ = tag, (res)->value_ = *getArrVal(h,k))
|
||||
|
||||
|
||||
LUAI_FUNC int luaH_getshortstr1 (Table *t, TString *key, TValue *res);
|
||||
LUAI_FUNC int luaH_getstr1 (Table *t, TString *key, TValue *res);
|
||||
LUAI_FUNC int luaH_get1 (Table *t, const TValue *key, TValue *res);
|
||||
LUAI_FUNC int luaH_getint1 (Table *t, lua_Integer key, TValue *res);
|
||||
|
||||
LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key);
|
||||
LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key,
|
||||
TValue *value);
|
||||
|
||||
Reference in New Issue
Block a user