MCPcopy
hub / github.com/di-sukharev/opencommit / passStringToWasm0

Function passStringToWasm0

out/cli.cjs:25524–25552  ·  view source on GitHub ↗
(arg, malloc, realloc)

Source from the content-addressed store, hash-verified

25522 };
25523 };
25524 function passStringToWasm0(arg, malloc, realloc) {
25525 if (realloc === void 0) {
25526 const buf = cachedTextEncoder.encode(arg);
25527 const ptr2 = malloc(buf.length, 1) >>> 0;
25528 getUint8Memory0().subarray(ptr2, ptr2 + buf.length).set(buf);
25529 WASM_VECTOR_LEN = buf.length;
25530 return ptr2;
25531 }
25532 let len = arg.length;
25533 let ptr = malloc(len, 1) >>> 0;
25534 const mem = getUint8Memory0();
25535 let offset = 0;
25536 for (; offset < len; offset++) {
25537 const code = arg.charCodeAt(offset);
25538 if (code > 127) break;
25539 mem[ptr + offset] = code;
25540 }
25541 if (offset !== len) {
25542 if (offset !== 0) {
25543 arg = arg.slice(offset);
25544 }
25545 ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
25546 const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
25547 const ret = encodeString(arg, view);
25548 offset += ret.written;
25549 }
25550 WASM_VECTOR_LEN = offset;
25551 return ptr;
25552 }
25553 function isLikeNone(x5) {
25554 return x5 === void 0 || x5 === null;
25555 }

Callers 5

constructorMethod · 0.85
encodeMethod · 0.85
encode_ordinaryMethod · 0.85
encode_with_unstableMethod · 0.85

Calls 5

getUint8Memory0Function · 0.85
encodeStringFunction · 0.85
encodeMethod · 0.80
setMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…