diff options
author | daurnimator <quae@daurnimator.com> | 2017-12-13 14:55:33 +1100 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-12-13 15:31:04 +1100 |
commit | 11a2421acaf2b39d19ee99933102c35e28fd13f8 (patch) | |
tree | 4abd1fa6ee063f75c634349a02702de7bc145a8b /src/defs.js | |
parent | 3e7c102eefbaae9e6bc839b11bba79aee1c5e040 (diff) | |
download | fengari-11a2421acaf2b39d19ee99933102c35e28fd13f8.tar.gz fengari-11a2421acaf2b39d19ee99933102c35e28fd13f8.tar.bz2 fengari-11a2421acaf2b39d19ee99933102c35e28fd13f8.zip |
Use Uint8Array to back strings
Diffstat (limited to 'src/defs.js')
-rw-r--r-- | src/defs.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/defs.js b/src/defs.js index 27498c6..381114b 100644 --- a/src/defs.js +++ b/src/defs.js @@ -131,10 +131,10 @@ class lua_Debug { } -const string_of = Array.of; +const string_of = Uint8Array.of.bind(Uint8Array); const is_luastring = function(s) { - return Array.isArray(s); + return s instanceof Uint8Array; }; /* test two lua strings for equality */ @@ -143,7 +143,7 @@ const luastring_cmp = function(a, b) { }; const to_jsstring = function(value, from, to) { - assert(is_luastring(value), "jsstring expects an array of bytes"); + assert(is_luastring(value), "jsstring expects a Uint8Array"); if (to === void 0) { to = value.length; @@ -240,6 +240,7 @@ const to_luastring = function(str, cache) { outU8Array[outIdx++] = 0x80 | (u & 63); } } + outU8Array = Uint8Array.from(outU8Array); if (cache) to_luastring_cache[str] = outU8Array; |