mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-29 13:06:06 +03:00
reduce the js file generated code
remove node test for browser test update usages revert test-support changes
This commit is contained in:
parent
40e1ee4484
commit
6d5afbb3d2
@ -568,7 +568,7 @@ impl<'a> Context<'a> {
|
||||
self.globals.push_str(&format!("
|
||||
function passStringToWasm(arg) {{
|
||||
{}
|
||||
const buf = textEncoder().encode(arg);
|
||||
const buf = cachedEncoder.encode(arg);
|
||||
const ptr = wasm.__wbindgen_malloc(buf.length);
|
||||
getUint8Memory().set(buf, ptr);
|
||||
return [ptr, buf.length];
|
||||
@ -665,13 +665,7 @@ impl<'a> Context<'a> {
|
||||
"));
|
||||
}
|
||||
self.globals.push_str(&format!("
|
||||
let cachedEncoder = null;
|
||||
function textEncoder() {{
|
||||
if (cachedEncoder)
|
||||
return cachedEncoder;
|
||||
cachedEncoder = new TextEncoder('utf-8');
|
||||
return cachedEncoder;
|
||||
}}
|
||||
let cachedEncoder = new TextEncoder('utf-8');
|
||||
"));
|
||||
}
|
||||
|
||||
@ -691,13 +685,7 @@ impl<'a> Context<'a> {
|
||||
"));
|
||||
}
|
||||
self.globals.push_str(&format!("
|
||||
let cachedDecoder = null;
|
||||
function textDecoder() {{
|
||||
if (cachedDecoder)
|
||||
return cachedDecoder;
|
||||
cachedDecoder = new TextDecoder('utf-8');
|
||||
return cachedDecoder;
|
||||
}}
|
||||
let cachedDecoder = new TextDecoder('utf-8');
|
||||
"));
|
||||
}
|
||||
|
||||
@ -709,7 +697,7 @@ impl<'a> Context<'a> {
|
||||
self.expose_uint8_memory();
|
||||
self.globals.push_str(&format!("
|
||||
function getStringFromWasm(ptr, len) {{
|
||||
return textDecoder().decode(getUint8Memory().slice(ptr, ptr + len));
|
||||
return cachedDecoder.decode(getUint8Memory().slice(ptr, ptr + len));
|
||||
}}
|
||||
"));
|
||||
}
|
||||
|
@ -272,4 +272,4 @@ fn run(cmd: &mut Command, program: &str) {
|
||||
println!("stderr ---\n{}", String::from_utf8_lossy(&output.stderr));
|
||||
}
|
||||
assert!(output.status.success());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user