From e602b73c35b74178a1dc36e4b0d0b442e63264d5 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Tue, 30 May 2017 16:02:52 +1000 Subject: Introduce function to adjust L.top --- src/lapi.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/lapi.js') diff --git a/src/lapi.js b/src/lapi.js index ceafa4a..4b5be04 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -151,13 +151,7 @@ const lua_settop = function(L, idx) { assert(-(idx + 1) <= L.top - (func + 1), "invalid new top"); newtop = L.top + idx + 1; /* 'subtract' index (index is negative) */ } - if (L.top < newtop) { - while (L.top < newtop) - L.stack[L.top++] = new TValue(CT.LUA_TNIL, null); - } else { - while (L.top > newtop) - delete L.stack[--L.top]; - } + ldo.adjust_top(L, newtop); }; const lua_pop = function(L, n) { -- cgit v1.2.3-54-g00ecf