From cf46bc042fb475c9e2d21fc8782ede28d05054c2 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 1 Jun 2017 17:40:18 +1000 Subject: src/llex.js: Avoid a .slice operation --- src/llex.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') 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; -- cgit v1.2.3-70-g09d2