mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-15 22:11:23 +00:00
Remove temporary object allocation
When returning a ptr/length for allocations and such wasm-bindgen's generated JS would previously return an array with two elements. It turns out this doesn't optimize well in all engines! (See #1031). It looks like we can optimize the array destructuring a bit more, but this is all generated code which doesn't need to be too readable so we can also remove the temporary allocation entirely and just pass the second element of this array through a global instead of the return value. Closes #1031
This commit is contained in:
@ -155,7 +155,7 @@ impl<'a, 'b> Js2Rust<'a, 'b> {
|
||||
format!("{}({})", func, name)
|
||||
};
|
||||
self.prelude(&format!(
|
||||
"const [ptr{i}, len{i}] = {val};",
|
||||
"const ptr{i} = {val};\nconst len{i} = WASM_VECTOR_LEN;",
|
||||
i = i,
|
||||
val = val,
|
||||
));
|
||||
|
Reference in New Issue
Block a user