diff options
author | daurnimator <quae@daurnimator.com> | 2017-06-01 18:15:00 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-06-01 18:15:00 +1000 |
commit | 5396746440918081a19f58bdc3fd784da683d69e (patch) | |
tree | aceedf73c84b49f42527984d0e2bac2f9bac4121 | |
parent | 9fea5d9d6b32a8694d150398c2fff55c6696ba5f (diff) | |
download | fengari-5396746440918081a19f58bdc3fd784da683d69e.tar.gz fengari-5396746440918081a19f58bdc3fd784da683d69e.tar.bz2 fengari-5396746440918081a19f58bdc3fd784da683d69e.zip |
src/lauxlib.js: Stop using .slice in skipBOM
-rw-r--r-- | src/lauxlib.js | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lauxlib.js b/src/lauxlib.js index c6a975c..84b625e 100644 --- a/src/lauxlib.js +++ b/src/lauxlib.js @@ -694,16 +694,17 @@ if (!WEB) { return bytes > 0 ? b.readUInt8() : null; }; + const utf8_bom = [0XEF, 0XBB, 0XBF]; /* UTF-8 BOM mark */ const skipBOM = function(lf) { - let p = [0XEF, 0XBB, 0XBF]; /* UTF-8 BOM mark */ lf.n = 0; let c; + let p = 0; do { c = getc(lf); - if (c === null || c !== p[0]) return c; - p = p.slice(1); + if (c === null || c !== utf8_bom[p]) return c; + p++; lf.buff[lf.n++] = c; /* to be read by the parser */ - } while (p.length > 0); + } while (p < utf8_bom.length); lf.n = 0; /* prefix matched; discard it */ return getc(lf); /* return next character */ }; |