aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-23 11:44:14 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-23 11:44:14 +1000
commitb2fb7a9302693fe5e164469eedb802b54e460347 (patch)
treee9e1399a9e9113783f2ca4bbb091279b004f3872 /src
parente3bdd1fea3665df28de25ed76f6399faf957179d (diff)
downloadfengari-b2fb7a9302693fe5e164469eedb802b54e460347.tar.gz
fengari-b2fb7a9302693fe5e164469eedb802b54e460347.tar.bz2
fengari-b2fb7a9302693fe5e164469eedb802b54e460347.zip
src/lmathlib.js: Optimise math.ult
See https://jsperf.com/unsigned-comparison
Diffstat (limited to 'src')
-rw-r--r--src/lmathlib.js4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/lmathlib.js b/src/lmathlib.js
index 8000b4d..4a62d52 100644
--- a/src/lmathlib.js
+++ b/src/lmathlib.js
@@ -132,9 +132,7 @@ const math_sqrt = function(L) {
const math_ult = function(L) {
let a = lauxlib.luaL_checkinteger(L, 1);
let b = lauxlib.luaL_checkinteger(L, 2);
- if (a < 0) a += 4294967296;
- if (b < 0) b += 4294967296;
- lua.lua_pushboolean(L, a < b);
+ lua.lua_pushboolean(L, (a >= 0)?(b<0 || a<b):(b<0 && a<b));
return 1;
};