From f7e5203a20ef41cf9bc59d339b4f85007a7f3764 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Mon, 15 May 2017 17:20:06 +1000 Subject: Separate ZIO and MBuffer data structures - lua_load no longer takes a null reader function --- src/lauxlib.js | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'src/lauxlib.js') diff --git a/src/lauxlib.js b/src/lauxlib.js index 3019bf3..c5a3b21 100644 --- a/src/lauxlib.js +++ b/src/lauxlib.js @@ -691,18 +691,9 @@ if (!WEB) { this.f = null; /* file being read */ this.buff = new Buffer(1024); /* area for reading file */ this.pos = 0; /* current position in file */ - this.binary = false; } } - const toDataView = function(buffer, bytes) { - let ab = new ArrayBuffer(bytes); - let au = new Uint8Array(ab); - for (let i = 0; i < bytes; i++) - au[i] = buffer[i]; - return new DataView(ab); - }; - const getF = function(L, ud) { let lf = ud; let bytes = 0; @@ -715,7 +706,7 @@ if (!WEB) { lf.pos += bytes; } if (bytes > 0) - return lf.binary ? toDataView(lf.buff, bytes) : lf.buff.slice(0, bytes); + return lf.buff.slice(0, bytes); /* slice on a node.js Buffer is 'free' */ else return null; }; @@ -794,7 +785,7 @@ if (!WEB) { let com = skipcomment(lf); /* check for signature first, as we don't want to add line number corrections in binary case */ if (com.c === lua.LUA_SIGNATURE.charCodeAt(0) && filename) { /* binary file? */ - lf.binary = true; + /* no need to re-open in node.js */ } else if (com.skipped) { /* read initial portion */ lf.buff[lf.n++] = '\n'.charCodeAt(0); /* add line to correct line numbers */ } -- cgit v1.2.3-54-g00ecf