summaryrefslogtreecommitdiff
path: root/src/lauxlib.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-12-13 11:21:19 +1100
committerdaurnimator <quae@daurnimator.com>2017-12-13 15:04:00 +1100
commitfa2cf3808b5b60c5e5cd5d5374196913d3afb74f (patch)
tree087b2a7c8ecaecb8588582e26222983ea330e2e7 /src/lauxlib.js
parentce967cb8576447a350a211c7205a8983c964a8df (diff)
downloadfengari-fa2cf3808b5b60c5e5cd5d5374196913d3afb74f.tar.gz
fengari-fa2cf3808b5b60c5e5cd5d5374196913d3afb74f.tar.bz2
fengari-fa2cf3808b5b60c5e5cd5d5374196913d3afb74f.zip
src/lauxlib.js: Implement luaL_prepbuffsize using a Uint8Array
Diffstat (limited to 'src/lauxlib.js')
-rw-r--r--src/lauxlib.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lauxlib.js b/src/lauxlib.js
index 32dd37c..b9b7078 100644
--- a/src/lauxlib.js
+++ b/src/lauxlib.js
@@ -16,6 +16,7 @@ class luaL_Buffer {
constructor() {
this.b = null;
this.L = null;
+ this.initb = null;
}
}
@@ -359,7 +360,8 @@ const luaL_optinteger = function(L, arg, def) {
};
const luaL_prepbuffsize = function(B, sz) {
- return B;
+ B.initb = new Uint8Array(sz);
+ return B.initb;
};
const luaL_buffinit = function(L, B) {
@@ -369,7 +371,7 @@ const luaL_buffinit = function(L, B) {
const luaL_buffinitsize = function(L, B, sz) {
luaL_buffinit(L, B);
- return B;
+ return luaL_prepbuffsize(B, sz);
};
const LUAL_BUFFERSIZE = 8192;
@@ -394,7 +396,9 @@ const luaL_addchar = function(B, c) {
};
const luaL_addsize = function(B, s) {
+ B.b = B.b.concat(Array.from(B.initb.subarray(0, s)));
B.n += s;
+ B.initb = null;
};
const luaL_pushresultsize = function(B, sz) {