summaryrefslogtreecommitdiff
path: root/src/lstring.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/lstring.js
parent3e7c102eefbaae9e6bc839b11bba79aee1c5e040 (diff)
downloadfengari-11a2421acaf2b39d19ee99933102c35e28fd13f8.tar.gz
fengari-11a2421acaf2b39d19ee99933102c35e28fd13f8.tar.bz2
fengari-11a2421acaf2b39d19ee99933102c35e28fd13f8.zip
Use Uint8Array to back strings
Diffstat (limited to 'src/lstring.js')
-rw-r--r--src/lstring.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lstring.js b/src/lstring.js
index c85e5b2..c8da56a 100644
--- a/src/lstring.js
+++ b/src/lstring.js
@@ -31,7 +31,7 @@ const luaS_eqlngstr = function(a, b) {
make sure this doesn't conflict with any of the anti-collision strategies in ltable */
const luaS_hash = function(str) {
assert(defs.is_luastring(str));
- return str.map(e => `${e}|`).join('');
+ return '|'+str.join('|');
};
const luaS_hashlongstr = function(ts) {
@@ -44,12 +44,13 @@ const luaS_hashlongstr = function(ts) {
/* variant that takes ownership of array */
const luaS_bless = function(L, str) {
+ assert(str instanceof Uint8Array);
return new TString(L, str);
};
/* makes a copy */
const luaS_new = function(L, str) {
- return luaS_bless(L, str.slice(0));
+ return luaS_bless(L, Uint8Array.from(str));
};
/* takes a js string */