mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Performance optimizations for large unit counts
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
void DllExport stackUpdate(lua_State* L, int& stackDepth, int initialStack = 0);
|
||||
void DllExport stackPop(lua_State* L, int popDepth = 1);
|
||||
void DllExport stackClean(lua_State* L, int stackDepth);
|
||||
json::value DllExport luaTableToJSON(lua_State* L, int index, bool logKeys = false);
|
||||
void DllExport luaTableToJSON(lua_State* L, int index, json::value& json, bool logKeys = false);
|
||||
|
||||
#define STACK_UPDATE stackUpdate(L, stackDepth, initialStack);
|
||||
#define STACK_INIT int stackDepth = 0; int initialStack = 0; stackUpdate(L, initialStack);
|
||||
|
||||
@@ -18,10 +18,8 @@ void stackClean(lua_State* L, int stackDepth)
|
||||
lua_pop(L, stackDepth);
|
||||
}
|
||||
|
||||
json::value luaTableToJSON(lua_State* L, int index, bool logKeys)
|
||||
void luaTableToJSON(lua_State* L, int index, json::value& json, bool logKeys)
|
||||
{
|
||||
auto json = json::value::object();
|
||||
|
||||
if (lua_istable(L, index))
|
||||
{
|
||||
STACK_INIT;
|
||||
@@ -38,7 +36,9 @@ json::value luaTableToJSON(lua_State* L, int index, bool logKeys)
|
||||
}
|
||||
if (lua_istable(L, -2))
|
||||
{
|
||||
json[to_wstring(key)] = luaTableToJSON(L, -2, logKeys);
|
||||
if (!json.has_object_field(to_wstring(key)))
|
||||
json[to_wstring(key)] = json::value::object();
|
||||
luaTableToJSON(L, -2, json[to_wstring(key)], logKeys);
|
||||
}
|
||||
else if (lua_isnumber(L, -2))
|
||||
{
|
||||
@@ -58,6 +58,5 @@ json::value luaTableToJSON(lua_State* L, int index, bool logKeys)
|
||||
|
||||
STACK_CLEAN;
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user