Fix inefficient InvalidateObjects

This commit is contained in:
Rochet2
2018-04-25 21:54:18 +03:00
parent 476cdcd2c3
commit 00ba8e518c
3 changed files with 23 additions and 52 deletions

View File

@@ -232,14 +232,6 @@ void Eluna::OpenLua()
// Register methods and functions
RegisterFunctions(this);
// Create hidden table with weak values
lua_newtable(L);
lua_newtable(L);
lua_pushstring(L, "v");
lua_setfield(L, -2, "__mode");
lua_setmetatable(L, -2);
lua_setfield(L, LUA_REGISTRYINDEX, ELUNA_OBJECT_STORE);
// Set lua require folder paths (scripts folder structure)
lua_getglobal(L, "package");
lua_pushstring(L, lua_requirepath.c_str());
@@ -526,18 +518,8 @@ void Eluna::RunScripts()
void Eluna::InvalidateObjects()
{
lua_pushstring(L, ELUNA_OBJECT_STORE);
lua_rawget(L, LUA_REGISTRYINDEX);
ASSERT(lua_istable(L, -1));
lua_pushnil(L);
while (lua_next(L, -2))
{
if (ElunaObject* elunaObj = CHECKOBJ<ElunaObject>(L, -1, false))
elunaObj->Invalidate();
lua_pop(L, 1);
}
lua_pop(L, 1);
++callstackid;
ASSERT(callstackid, "Callstackid overflow");
}
void Eluna::Report(lua_State* _L)