diff options
author | daurnimator <quae@daurnimator.com> | 2017-12-15 14:56:04 +1100 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-12-15 14:56:04 +1100 |
commit | 8249248f80467f1660509a30623f40bb9ff1eba7 (patch) | |
tree | 3774f145fa960592364607cd5fd221d740ca405b /src | |
parent | b162ffe744bc407ad4035674f5c05848a460b58f (diff) | |
download | fengari-8249248f80467f1660509a30623f40bb9ff1eba7.tar.gz fengari-8249248f80467f1660509a30623f40bb9ff1eba7.tar.bz2 fengari-8249248f80467f1660509a30623f40bb9ff1eba7.zip |
src/lapi.js: Have lua_todataview return view over actual underlying Uint8Array
Diffstat (limited to 'src')
-rw-r--r-- | src/lapi.js | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/src/lapi.js b/src/lapi.js index afa94ce..111735f 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -672,19 +672,8 @@ const lua_toljsstring = function(L, idx) { const lua_tojsstring = lua_toljsstring; const lua_todataview = function(L, idx) { - let o = index2addr(L, idx); - - if (!o.ttisstring()) { - if (!lvm.cvt2str(o)) { /* not convertible? */ - return null; - } - lobject.luaO_tostring(L, o); - } - - let dv = new DataView(new ArrayBuffer(o.vslen())); - o.svalue().forEach((e, i) => dv.setUint8(i, e, true)); - - return dv; + let u8 = lua_tolstring(L, idx); + return new DataView(u8.buffer, u8.byteOffset, u8.byteLength); }; const lua_rawlen = function(L, idx) { |