summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-06-08 16:49:37 +1000
committerdaurnimator <quae@daurnimator.com>2017-06-08 16:49:37 +1000
commitc1a96e0cd2d0b02da6beb0b0fd07bd91fdb91288 (patch)
treea7e863133be03927fb95ab82cce0cb5af55c3965
parentc129a1d95b44be63c840d95f94409d7333d440cc (diff)
downloadfengari-c1a96e0cd2d0b02da6beb0b0fd07bd91fdb91288.tar.gz
fengari-c1a96e0cd2d0b02da6beb0b0fd07bd91fdb91288.tar.bz2
fengari-c1a96e0cd2d0b02da6beb0b0fd07bd91fdb91288.zip
src/lvm.js: Clean up 'forlimit'
- 'casted' property was pointless - Avoid calling unless operands are known to be integers
-rw-r--r--src/lvm.js7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/lvm.js b/src/lvm.js
index 9d702fd..e641d7e 100644
--- a/src/lvm.js
+++ b/src/lvm.js
@@ -533,9 +533,10 @@ const luaV_execute = function(L) {
let init = L.stack[ra];
let plimit = L.stack[ra + 1];
let pstep = L.stack[ra + 2];
- let forlim = forlimit(plimit, pstep.value);
+ let forlim;
- if (init.ttisinteger() && pstep.ttisinteger() && forlim.casted) { /* all values are integer */
+ if (init.ttisinteger() && pstep.ttisinteger() && (forlim = forlimit(plimit, pstep.value))) {
+ /* all values are integer */
let initv = forlim.stopnow ? 0 : init.value;
plimit.value = forlim.ilimit;
init.value = (initv - pstep.value)|0;
@@ -746,7 +747,6 @@ const forlimit = function(obj, step) {
}
return {
- casted: true,
stopnow: stopnow,
ilimit: ilimit
};
@@ -1061,7 +1061,6 @@ module.exports.cvt2str = cvt2str;
module.exports.cvt2num = cvt2num;
module.exports.dojump = dojump;
module.exports.donextjump = donextjump;
-module.exports.forlimit = forlimit;
module.exports.gettable = gettable;
module.exports.luaV_concat = luaV_concat;
module.exports.luaV_div = luaV_div;