summaryrefslogtreecommitdiff
path: root/src/lobject.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/lobject.js
parent3e7c102eefbaae9e6bc839b11bba79aee1c5e040 (diff)
downloadfengari-11a2421acaf2b39d19ee99933102c35e28fd13f8.tar.gz
fengari-11a2421acaf2b39d19ee99933102c35e28fd13f8.tar.bz2
fengari-11a2421acaf2b39d19ee99933102c35e28fd13f8.zip
Use Uint8Array to back strings
Diffstat (limited to 'src/lobject.js')
-rw-r--r--src/lobject.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lobject.js b/src/lobject.js
index 707cdf8..18adb27 100644
--- a/src/lobject.js
+++ b/src/lobject.js
@@ -312,19 +312,20 @@ const luaO_chunkid = function(source, bufflen) {
out = source.slice(1);
else { /* add '...' before rest of name */
bufflen -= RETS.length;
- out = RETS.concat(source.slice(1 + l - bufflen));
+ out = Uint8Array.from(Array.from(RETS).concat(Array.from(source.subarray(1 + l - bufflen))));
}
} else { /* string; format as [string "source"] */
let nli = source.indexOf(char['\n']); /* find first new line (if any) */
- out = PRE; /* add prefix */
+ out = Array.from(PRE); /* add prefix */
bufflen -= PRE.length + RETS.length + POS.length + 1; /* save space for prefix+suffix+'\0' */
if (l < bufflen && nli === -1) { /* small one-line source? */
- out = out.concat(source, POS); /* keep it */
+ out = out.concat(Array.from(source), Array.from(POS)); /* keep it */
} else {
if (nli !== -1) l = nli; /* stop at first newline */
if (l > bufflen) l = bufflen;
- out = out.concat(source.slice(0, l), RETS, POS);
+ out = out.concat(Array.from(source.subarray(0, l)), Array.from(RETS), Array.from(POS));
}
+ out = Uint8Array.from(out);
}
return out;
};