diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-02-15 13:34:29 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-02-15 13:34:29 -0200 |
| commit | 0682fe816929da2e5abe8e191ad9c8509e6bfc12 (patch) | |
| tree | bac8b079fde63e7f2e436e51ed6fd571dfd6f195 /ltm.c | |
| parent | b1379936cf35787d3ef3aab82d1607a3e1562eef (diff) | |
| download | lua-0682fe816929da2e5abe8e191ad9c8509e6bfc12.tar.gz lua-0682fe816929da2e5abe8e191ad9c8509e6bfc12.tar.bz2 lua-0682fe816929da2e5abe8e191ad9c8509e6bfc12.zip | |
some simplifications/optimizations in returns from Lua functions
Diffstat (limited to 'ltm.c')
| -rw-r--r-- | ltm.c | 10 |
1 files changed, 6 insertions, 4 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltm.c,v 2.59 2018/02/07 15:18:04 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 2.60 2018/02/09 15:16:06 roberto Exp roberto $ |
| 3 | ** Tag methods | 3 | ** Tag methods |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -222,10 +222,12 @@ void luaT_adjustvarargs (lua_State *L, int nfixparams, CallInfo *ci) { | |||
| 222 | int nextra = actual - nfixparams; /* number of extra arguments */ | 222 | int nextra = actual - nfixparams; /* number of extra arguments */ |
| 223 | ci->u.l.nextraargs = nextra; | 223 | ci->u.l.nextraargs = nextra; |
| 224 | checkstackGC(L, nfixparams + 1); | 224 | checkstackGC(L, nfixparams + 1); |
| 225 | /* copy function and fixed parameters to the top of the stack */ | 225 | /* copy function to the top of the stack */ |
| 226 | for (i = 0; i <= nfixparams; i++) { | 226 | setobjs2s(L, L->top++, ci->func); |
| 227 | /* move fixed parameters to the top of the stack */ | ||
| 228 | for (i = 1; i <= nfixparams; i++) { | ||
| 227 | setobjs2s(L, L->top++, ci->func + i); | 229 | setobjs2s(L, L->top++, ci->func + i); |
| 228 | setnilvalue(s2v(ci->func + i)); /* erase original copy (for GC) */ | 230 | setnilvalue(s2v(ci->func + i)); /* erase original parameter (for GC) */ |
| 229 | } | 231 | } |
| 230 | ci->func += actual + 1; | 232 | ci->func += actual + 1; |
| 231 | ci->top += actual + 1; | 233 | ci->top += actual + 1; |
