aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2018-02-04 15:41:53 -0800
committerdaurnimator <quae@daurnimator.com>2018-02-04 15:41:53 -0800
commit33814ee61baed1b749ba2bdf4a359f092d21c1d1 (patch)
tree2942b324db68062f6fa55e4750e321905badddb6 /src
parent0ba420d8a7c88ac52df0ba2e20c026ed9b8e5c70 (diff)
downloadfengari-33814ee61baed1b749ba2bdf4a359f092d21c1d1.tar.gz
fengari-33814ee61baed1b749ba2bdf4a359f092d21c1d1.tar.bz2
fengari-33814ee61baed1b749ba2bdf4a359f092d21c1d1.zip
src/lapi.js: in lua_pcallk only create CallS object when required
Diffstat (limited to 'src')
-rw-r--r--src/lapi.js22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/lapi.js b/src/lapi.js
index 7c9317e..f7347d1 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -993,14 +993,8 @@ const lua_pcallk = function(L, nargs, nresults, errfunc, ctx, k) {
api_checknelems(L, nargs + 1);
api_check(L, L.status === LUA_OK, "cannot do calls on non-normal thread");
checkresults(L, nargs, nresults);
- let c = {
- func: null,
- funcOff: NaN,
- nresults: NaN
- };
let status;
let func;
-
if (errfunc === 0)
func = 0;
else {
@@ -1008,24 +1002,24 @@ const lua_pcallk = function(L, nargs, nresults, errfunc, ctx, k) {
// TODO: api_checkstackindex(L, errfunc, o);
func = index2addr_(L, errfunc);
}
-
- c.funcOff = L.top - (nargs + 1); /* function to be called */
- c.func = L.stack[c.funcOff];
-
+ let funcOff = L.top - (nargs + 1); /* function to be called */
if (k === null || L.nny > 0) { /* no continuation or no yieldable? */
- c.nresults = nresults; /* do a 'conventional' protected call */
- status = ldo.luaD_pcall(L, f_call, c, c.funcOff, func);
+ let c = {
+ funcOff: funcOff,
+ nresults: nresults /* do a 'conventional' protected call */
+ };
+ status = ldo.luaD_pcall(L, f_call, c, funcOff, func);
} else { /* prepare continuation (call is already protected by 'resume') */
let ci = L.ci;
ci.c_k = k; /* prepare continuation (call is already protected by 'resume') */
ci.c_ctx = ctx; /* prepare continuation (call is already protected by 'resume') */
/* save information for error recovery */
- ci.extra = c.funcOff;
+ ci.extra = funcOff;
ci.c_old_errfunc = L.errfunc;
L.errfunc = func;
ci.callstatus &= ~lstate.CIST_OAH | L.allowhook;
ci.callstatus |= lstate.CIST_YPCALL; /* function can do error recovery */
- ldo.luaD_call(L, c.funcOff, nresults); /* do the call */
+ ldo.luaD_call(L, funcOff, nresults); /* do the call */
ci.callstatus &= ~lstate.CIST_YPCALL;
L.errfunc = ci.c_old_errfunc;
status = LUA_OK;