aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-12-14 14:34:36 +1100
committerdaurnimator <quae@daurnimator.com>2017-12-14 14:40:55 +1100
commitf3fbb2d8460f8d3a419a07f2efa569b2422a8f04 (patch)
tree75222bfb2f88a5d27ed7c9b63129a24b6021b16e /src
parent144d14797751e7bf4de7d1444b4122f464a39014 (diff)
downloadfengari-f3fbb2d8460f8d3a419a07f2efa569b2422a8f04.tar.gz
fengari-f3fbb2d8460f8d3a419a07f2efa569b2422a8f04.tar.bz2
fengari-f3fbb2d8460f8d3a419a07f2efa569b2422a8f04.zip
src/lstrlib.js: Optimise nospecials, js .indexOf has no issues with a null byte
Diffstat (limited to 'src')
-rw-r--r--src/lstrlib.js21
1 files changed, 5 insertions, 16 deletions
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<l; i++) {
+ if (SPECIALS.indexOf(p[i]) !== -1)
+ return false;
+ }
+ return true;
};
const prepstate = function(ms, L, s, ls, p, lp) {