diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-11-26 18:23:40 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-11-26 18:23:40 -0300 |
commit | 65d2294454ab68d164154c7ce05caa50bd97d143 (patch) | |
tree | 6cd1a6d00eaf7156d1537d165de26abf82787782 /lstate.c | |
parent | 131e3fd814a6e818b412407a222186aab08f3525 (diff) | |
download | lua-github-65d2294454ab68d164154c7ce05caa50bd97d143.tar.gz |
Changed access to global table in the registry
The global table is always in the array part of the registry; we can
use this fact to make its access slightly more efficient.
Diffstat (limited to 'lstate.c')
-rw-r--r-- | lstate.c | 9 |
1 files changed, 3 insertions, 6 deletions
@@ -213,17 +213,14 @@ static void freestack (lua_State *L) { ** Create registry table and its predefined values */ static void init_registry (lua_State *L, global_State *g) { - TValue temp; /* create registry */ Table *registry = luaH_new(L); sethvalue(L, &g->l_registry, registry); luaH_resize(L, registry, LUA_RIDX_LAST, 0); /* registry[LUA_RIDX_MAINTHREAD] = L */ - setthvalue(L, &temp, L); /* temp = L */ - luaH_setint(L, registry, LUA_RIDX_MAINTHREAD, &temp); - /* registry[LUA_RIDX_GLOBALS] = table of globals */ - sethvalue(L, &temp, luaH_new(L)); /* temp = new table (global table) */ - luaH_setint(L, registry, LUA_RIDX_GLOBALS, &temp); + setthvalue(L, ®istry->array[LUA_RIDX_MAINTHREAD - 1], L); + /* registry[LUA_RIDX_GLOBALS] = new table (table of globals) */ + sethvalue(L, ®istry->array[LUA_RIDX_GLOBALS - 1], luaH_new(L)); } |