(arg, malloc, realloc)
| 56 | }); |
| 57 | |
| 58 | function passStringToWasm0(arg, malloc, realloc) { |
| 59 | |
| 60 | if (realloc === undefined) { |
| 61 | const buf = cachedTextEncoder.encode(arg); |
| 62 | const ptr = malloc(buf.length, 1) >>> 0; |
| 63 | getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); |
| 64 | WASM_VECTOR_LEN = buf.length; |
| 65 | return ptr; |
| 66 | } |
| 67 | |
| 68 | let len = arg.length; |
| 69 | let ptr = malloc(len, 1) >>> 0; |
| 70 | |
| 71 | const mem = getUint8Memory0(); |
| 72 | |
| 73 | let offset = 0; |
| 74 | |
| 75 | for (; offset < len; offset++) { |
| 76 | const code = arg.charCodeAt(offset); |
| 77 | if (code > 0x7F) break; |
| 78 | mem[ptr + offset] = code; |
| 79 | } |
| 80 | |
| 81 | if (offset !== len) { |
| 82 | if (offset !== 0) { |
| 83 | arg = arg.slice(offset); |
| 84 | } |
| 85 | ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; |
| 86 | const view = getUint8Memory0().subarray(ptr + offset, ptr + len); |
| 87 | const ret = encodeString(arg, view); |
| 88 | |
| 89 | offset += ret.written; |
| 90 | } |
| 91 | |
| 92 | WASM_VECTOR_LEN = offset; |
| 93 | return ptr; |
| 94 | } |
| 95 | |
| 96 | function isLikeNone(x) { |
| 97 | return x === undefined || x === null; |
no test coverage detected