summaryrefslogtreecommitdiff
path: root/src/llex.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-12-13 14:55:33 +1100
committerdaurnimator <quae@daurnimator.com>2017-12-13 15:31:04 +1100
commit11a2421acaf2b39d19ee99933102c35e28fd13f8 (patch)
tree4abd1fa6ee063f75c634349a02702de7bc145a8b /src/llex.js
parent3e7c102eefbaae9e6bc839b11bba79aee1c5e040 (diff)
downloadfengari-11a2421acaf2b39d19ee99933102c35e28fd13f8.tar.gz
fengari-11a2421acaf2b39d19ee99933102c35e28fd13f8.tar.bz2
fengari-11a2421acaf2b39d19ee99933102c35e28fd13f8.zip
Use Uint8Array to back strings
Diffstat (limited to 'src/llex.js')
-rw-r--r--src/llex.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/llex.js b/src/llex.js
index 779557a..9e4bed4 100644
--- a/src/llex.js
+++ b/src/llex.js
@@ -112,6 +112,8 @@ const save = function(ls, c) {
if (b.n + 1 > b.buffer.length) {
if (b.buffer.length >= llimits.MAX_INT/2)
lexerror(ls, defs.to_luastring("lexical element too long", true), 0);
+ let newsize = b.buffer.length*2;
+ lzio.luaZ_resizebuffer(ls.L, b, newsize);
}
b.buffer[b.n++] = c < 0 ? 255 + c + 1 : c;
};
@@ -192,6 +194,7 @@ const luaX_setinput = function(L, ls, z, source, firstchar) {
ls.lastline = 1;
ls.source = source;
ls.envn = lstring.luaS_bless(L, LUA_ENV);
+ lzio.luaZ_resizebuffer(L, ls.buff, llimits.LUA_MINBUFFER); /* initialize buffer */
};
const check_next1 = function(ls, c) {
@@ -369,7 +372,7 @@ const readutf8desc = function(ls) {
};
const utf8esc = function(ls) {
- let buff = new Array(lobject.UTF8BUFFSZ);
+ let buff = new Uint8Array(lobject.UTF8BUFFSZ);
let n = lobject.luaO_utf8esc(buff, readutf8desc(ls));
for (; n > 0; n--) /* add 'buff' to string */
save(ls, buff[lobject.UTF8BUFFSZ - n]);