From 5396746440918081a19f58bdc3fd784da683d69e Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 1 Jun 2017 18:15:00 +1000 Subject: src/lauxlib.js: Stop using .slice in skipBOM --- src/lauxlib.js | 9 +++++---- 1 file 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 */ }; -- cgit v1.2.3-70-g09d2