summaryrefslogtreecommitdiff
path: root/src/llex.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-06-01 17:40:18 +1000
committerdaurnimator <quae@daurnimator.com>2017-06-01 17:40:18 +1000
commitcf46bc042fb475c9e2d21fc8782ede28d05054c2 (patch)
tree92509958fba706e0bb1c20752ea2f2a46ec50689 /src/llex.js
parent51d0f9909b3d5a4f7ae3c13eae9faf26e50eab7c (diff)
downloadfengari-cf46bc042fb475c9e2d21fc8782ede28d05054c2.tar.gz
fengari-cf46bc042fb475c9e2d21fc8782ede28d05054c2.tar.bz2
fengari-cf46bc042fb475c9e2d21fc8782ede28d05054c2.zip
src/llex.js: Avoid a .slice operation
Diffstat (limited to 'src/llex.js')
-rw-r--r--src/llex.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/llex.js b/src/llex.js
index 905be5a..8abd27b 100644
--- a/src/llex.js
+++ b/src/llex.js
@@ -463,7 +463,8 @@ const read_string = function(ls, del, seminfo) {
};
const isreserved = function(w) {
- return luaX_tokens.slice(0, 22).indexOf(w) >= 0;
+ let kidx = luaX_tokens.indexOf(w);
+ return kidx >= 0 && kidx <= 22;
};
const llex = function(ls, seminfo) {
@@ -573,8 +574,8 @@ const llex = function(ls, seminfo) {
let ts = luaX_newstring(ls, ls.buff.buffer);
seminfo.ts = ts;
- let kidx = luaX_tokens.slice(0, 22).indexOf(defs.to_jsstring(ts.getstr()));
- if (kidx >= 0) /* reserved word? */
+ let kidx = luaX_tokens.indexOf(defs.to_jsstring(ts.getstr()));
+ if (kidx >= 0 && kidx <= 22) /* reserved word? */
return kidx + FIRST_RESERVED;
else
return R.TK_NAME;