Merge pull request #879 from alexcrichton/closure-zst

Improve codegen for `Closure<T>`
This commit is contained in:
Alex Crichton
2018-10-01 14:41:13 -07:00
committed by GitHub
7 changed files with 156 additions and 45 deletions

View File

@ -327,9 +327,13 @@ impl<'a> Context<'a> {
Ok(String::from(
"
function(i) {
let obj = getObject(i).original;
obj.a = obj.b = 0;
const obj = getObject(i).original;
dropRef(i);
if (obj.cnt-- == 1) {
obj.a = 0;
return 1;
}
return 0;
}
",
))
@ -337,13 +341,7 @@ impl<'a> Context<'a> {
self.bind("__wbindgen_cb_forget", &|me| {
me.expose_drop_ref();
Ok(String::from(
"
function(i) {
dropRef(i);
}
",
))
Ok("dropRef".to_string())
})?;
self.bind("__wbindgen_json_parse", &|me| {