From f3fbb2d8460f8d3a419a07f2efa569b2422a8f04 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 14 Dec 2017 14:34:36 +1100 Subject: src/lstrlib.js: Optimise nospecials, js .indexOf has no issues with a null byte --- src/lstrlib.js | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/lstrlib.js b/src/lstrlib.js index 23b0404..6a0da58 100644 --- a/src/lstrlib.js +++ b/src/lstrlib.js @@ -1113,22 +1113,11 @@ const push_captures = function(ms, s, e) { }; const nospecials = function(p, l) { - let upto = 0; - do { - let special = false; - let supto = p.slice(upto); - for (let i = 0; i < SPECIALS.length; i++) { - if (supto.indexOf(SPECIALS[i]) > -1) { - special = true; - break; - } - } - - if (special) - return false; /* pattern has a special character */ - upto = upto + 1; /* may have more after \0 */ - } while (upto <= l); - return true; /* no special chars found */ + for (let i=0; i