Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize tic api call performance in LUA. #1628

Merged
merged 1 commit into from
Nov 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/api/lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,18 @@ static s32 getLuaNumber(lua_State* lua, s32 index)

static void registerLuaFunction(tic_core* core, lua_CFunction func, const char *name)
{
lua_pushcfunction(core->currentVM, func);
lua_pushlightuserdata(core->currentVM, core);
lua_pushcclosure(core->currentVM, func, 1);
lua_setglobal(core->currentVM, name);
}

static tic_core* getLuaCore(lua_State* lua)
{
tic_core* core = lua_touserdata(lua, lua_upvalueindex(1));
return core;
}

static tic_core* getLuaCoreGlobal(lua_State* lua)
{
lua_getglobal(lua, TicCore);
tic_core* core = lua_touserdata(lua, -1);
Expand Down Expand Up @@ -1356,7 +1363,7 @@ static void lua_open_builtins(lua_State *lua)

static void checkForceExit(lua_State *lua, lua_Debug *luadebug)
{
tic_core* core = getLuaCore(lua);
tic_core* core = getLuaCoreGlobal(lua);

tic_tick_data* tick = core->data;

Expand Down