From d8ca24c817c75e4596c0c60b7d0b1ecbbba81f8d Mon Sep 17 00:00:00 2001 From: frederic wagner Date: Sun, 6 Nov 2022 07:56:54 +0100 Subject: [PATCH] Revert "testing strings instead of vec" This reverts commit 8dcc587c4510935a364e99929ef2da2a0ef123f8. --- apps/gipy_uploader/pkg/gpconv.d.ts | 4 ++-- apps/gipy_uploader/pkg/gpconv.js | 15 ++++++--------- apps/gipy_uploader/pkg/gpconv_bg.wasm | Bin 204462 -> 204497 bytes 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/apps/gipy_uploader/pkg/gpconv.d.ts b/apps/gipy_uploader/pkg/gpconv.d.ts index 9ded6a888..e97d230c3 100644 --- a/apps/gipy_uploader/pkg/gpconv.d.ts +++ b/apps/gipy_uploader/pkg/gpconv.d.ts @@ -2,9 +2,9 @@ /* eslint-disable */ /** * @param {string} input_str -* @returns {string} +* @returns {Uint8Array} */ -export function convert_gpx_strings(input_str: string): string; +export function convert_gpx_strings(input_str: string): Uint8Array; export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; diff --git a/apps/gipy_uploader/pkg/gpconv.js b/apps/gipy_uploader/pkg/gpconv.js index 7a9d8a777..58b6d4f26 100644 --- a/apps/gipy_uploader/pkg/gpconv.js +++ b/apps/gipy_uploader/pkg/gpconv.js @@ -74,16 +74,12 @@ function getInt32Memory0() { return cachedInt32Memory0; } -const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); - -cachedTextDecoder.decode(); - -function getStringFromWasm0(ptr, len) { - return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +function getArrayU8FromWasm0(ptr, len) { + return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); } /** * @param {string} input_str -* @returns {string} +* @returns {Uint8Array} */ export function convert_gpx_strings(input_str) { try { @@ -93,10 +89,11 @@ export function convert_gpx_strings(input_str) { wasm.convert_gpx_strings(retptr, ptr0, len0); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; - return getStringFromWasm0(r0, r1); + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1); + return v1; } finally { wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(r0, r1); } } diff --git a/apps/gipy_uploader/pkg/gpconv_bg.wasm b/apps/gipy_uploader/pkg/gpconv_bg.wasm index cf24562a348c0302072b7df36fa145952ee891f5..f71a5c38cabe4d54fe866224fc27ee2d46d21274 100644 GIT binary patch delta 367 zcmYL@F-rqM6olWt-Mu@{6zK)oPA#~Bxg$t&Sr9vZQPS2Y zB%*EW71ZE^=RbU{5yo)gk|c&tdr9^ERNy9pME9B9@7Phb8pAv&{H)~25o36?OqyEj zYJ@|lS%m$P*FpZ`t=E;-OyZj>v{;RFtq^sIQ^x~|#*s*Tbpbp4T=K4@E;;@GT;ixV a@ywyG0tMA?%pWpwY_e06ktdVk`^_J0+f*R{ delta 323 zcmXZWJxc>Y5C-7cxxEjL6xRvCVmq&~or8Yq_ev&n?z8=BDhV;6bcqWf(h6d zP)KQ!6iPxO+W0H3(4BbIGw<%pFw0r(VOAR-$l!Gz553;xP#y_;<=5@VPun7gFJDOw z4ftd`-SdcG&EvP<(xB7CdUcnkVM}3(KnPqXybqOZip(22HRLd0;~ZAOzXKLX+*G;G zMugW+6%$@^w#UI