From c7b6fa63459d411cd7b20ea0de3dc2f4cf7e2a2f Mon Sep 17 00:00:00 2001 From: daurnimator Date: Fri, 5 May 2017 18:05:02 +1000 Subject: src/lvm.js: Optimise variable declarations Oddly 'const' on OCi helps, but on anything else dramatically increases runtime Otherwise the reduced scope for other variables is a tiny bit faster --- src/lvm.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/lvm.js b/src/lvm.js index 7c827a8..41b17c8 100644 --- a/src/lvm.js +++ b/src/lvm.js @@ -98,28 +98,26 @@ const RKC = function(L, base, k, i) { }; const luaV_execute = function(L) { - let OCi = OC.OpCodesI; + const OCi = OC.OpCodesI; let ci = L.ci; - let opcode, k, base, i, ra; - var cl; ci.callstatus |= lstate.CIST_FRESH; newframe: for (;;) { assert(ci === L.ci); - cl = ci.func.value; - k = cl.p.k; - base = ci.l_base; + let cl = ci.func.value; + let k = cl.p.k; + let base = ci.l_base; - i = ci.l_savedpc[ci.pcOff++]; + let i = ci.l_savedpc[ci.pcOff++]; if (L.hookmask & (defs.LUA_MASKLINE | defs.LUA_MASKCOUNT)) { ldebug.luaG_traceexec(L); base = ci.l_base; } - ra = RA(L, base, i); - opcode = i.opcode; + let ra = RA(L, base, i); + let opcode = i.opcode; if (i.breakpoint) // TODO: remove, used until lapi return; -- cgit v1.2.3-70-g09d2