aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2018-01-29 20:48:26 +1100
committerdaurnimator <quae@daurnimator.com>2018-01-29 22:07:02 +1100
commitcb38849ddfdba715b5d85f438f8479743e5d7a11 (patch)
tree022725884707d95fcc558363bbd8c038fad60668
parent313f55905253697fe4966f979865296aeaa7a801 (diff)
downloadfengari-cb38849ddfdba715b5d85f438f8479743e5d7a11.tar.gz
fengari-cb38849ddfdba715b5d85f438f8479743e5d7a11.tar.bz2
fengari-cb38849ddfdba715b5d85f438f8479743e5d7a11.zip
src/lapi.js: optimise+minify getupvalref usage
-rw-r--r--src/lapi.js13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/lapi.js b/src/lapi.js
index 8ed67f5..0ea700c 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -1081,9 +1081,8 @@ const getupvalref = function(L, fidx, n) {
let f = fi.value;
api_check(L, 1 <= n && n <= f.p.upvalues.length, "invalid upvalue index");
return {
- closure: f,
- upval: f.upvals[n - 1],
- upvalOff: n - 1
+ f: f,
+ i: n - 1
};
};
@@ -1091,7 +1090,8 @@ const lua_upvalueid = function(L, fidx, n) {
let fi = index2addr(L, fidx);
switch (fi.ttype()) {
case LUA_TLCL: { /* lua closure */
- return getupvalref(L, fidx, n).upval;
+ let ref = getupvalref(L, fidx, n);
+ return ref.f.upvals[ref.i];
}
case LUA_TCCL: { /* C closure */
let f = fi.value;
@@ -1108,9 +1108,8 @@ const lua_upvalueid = function(L, fidx, n) {
const lua_upvaluejoin = function(L, fidx1, n1, fidx2, n2) {
let ref1 = getupvalref(L, fidx1, n1);
let ref2 = getupvalref(L, fidx2, n2);
- let up2 = ref2.upval;
- let f1 = ref1.closure;
- f1.upvals[ref1.upvalOff] = up2;
+ let up2 = ref2.f.upvals[ref2.i];
+ ref1.f.upvals[ref1.i] = up2;
};
// This functions are only there for compatibility purposes