diff options
author | daurnimator <quae@daurnimator.com> | 2017-05-23 11:44:14 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-05-23 11:44:14 +1000 |
commit | b2fb7a9302693fe5e164469eedb802b54e460347 (patch) | |
tree | e9e1399a9e9113783f2ca4bbb091279b004f3872 /src/lmathlib.js | |
parent | e3bdd1fea3665df28de25ed76f6399faf957179d (diff) | |
download | fengari-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/lmathlib.js')
-rw-r--r-- | src/lmathlib.js | 4 |
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; }; |