From 11a2421acaf2b39d19ee99933102c35e28fd13f8 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Wed, 13 Dec 2017 14:55:33 +1100 Subject: Use Uint8Array to back strings --- src/lstring.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/lstring.js') 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 */ -- cgit v1.2.3-70-g09d2