From 0682fe816929da2e5abe8e191ad9c8509e6bfc12 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 15 Feb 2018 13:34:29 -0200 Subject: some simplifications/optimizations in returns from Lua functions --- ltm.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'ltm.c') diff --git a/ltm.c b/ltm.c index d88b636b..be7dc4f0 100644 --- a/ltm.c +++ b/ltm.c @@ -1,5 +1,5 @@ /* -** $Id: ltm.c,v 2.59 2018/02/07 15:18:04 roberto Exp roberto $ +** $Id: ltm.c,v 2.60 2018/02/09 15:16:06 roberto Exp roberto $ ** Tag methods ** See Copyright Notice in lua.h */ @@ -222,10 +222,12 @@ void luaT_adjustvarargs (lua_State *L, int nfixparams, CallInfo *ci) { int nextra = actual - nfixparams; /* number of extra arguments */ ci->u.l.nextraargs = nextra; checkstackGC(L, nfixparams + 1); - /* copy function and fixed parameters to the top of the stack */ - for (i = 0; i <= nfixparams; i++) { + /* copy function to the top of the stack */ + setobjs2s(L, L->top++, ci->func); + /* move fixed parameters to the top of the stack */ + for (i = 1; i <= nfixparams; i++) { setobjs2s(L, L->top++, ci->func + i); - setnilvalue(s2v(ci->func + i)); /* erase original copy (for GC) */ + setnilvalue(s2v(ci->func + i)); /* erase original parameter (for GC) */ } ci->func += actual + 1; ci->top += actual + 1; -- cgit v1.2.3-55-g6feb