mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
The Variant class is now meant to be used on the stack instead of allocated on the heap. As a result (and because of related changes), performance of Channels has roughly doubled when pushing and popping most types.
This commit is contained in:
@@ -33,26 +33,22 @@ LuaThread *luax_checkthread(lua_State *L, int idx)
|
||||
int w_Thread_start(lua_State *L)
|
||||
{
|
||||
LuaThread *t = luax_checkthread(L, 1);
|
||||
std::vector<Variant> args;
|
||||
int nargs = lua_gettop(L) - 1;
|
||||
Variant **args = 0;
|
||||
|
||||
if (nargs > 0)
|
||||
Variant v;
|
||||
for (int i = 0; i < nargs; ++i)
|
||||
{
|
||||
args = new Variant*[nargs];
|
||||
for (int i = 0; i < nargs; ++i)
|
||||
if (!Variant::fromLua(L, i+2, &v))
|
||||
{
|
||||
args[i] = Variant::fromLua(L, i+2);
|
||||
if (!args[i])
|
||||
{
|
||||
for (int j = i; j >= 0; j--)
|
||||
delete args[j];
|
||||
delete[] args;
|
||||
return luaL_argerror(L, i+2, "boolean, number, string, love type, or flat table expected");
|
||||
}
|
||||
args.clear();
|
||||
return luaL_argerror(L, i+2, "boolean, number, string, love type, or flat table expected");
|
||||
}
|
||||
|
||||
args.push_back(v);
|
||||
}
|
||||
|
||||
luax_pushboolean(L, t->start(args, nargs));
|
||||
luax_pushboolean(L, t->start(args));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user