Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slight optimization in codegen #856

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions crates/cli/src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,18 @@ impl Generator {
.make_linker(Some(Rc::new(move |engine| {
let mut linker = Linker::new(engine);
wasmtime_wasi::preview1::add_to_linker_sync(&mut linker, move |cx| {
// The underlying buffer backing the pipe is an Arc
// so the cloning should be fast.
let config = STDIN_PIPE.get().unwrap().clone();
cx.wasi_ctx = Some(
WasiCtxBuilder::new()
.stdin(config)
.inherit_stdout()
.inherit_stderr()
.build_p1(),
);
if cx.wasi_ctx.is_none() {
// The underlying buffer backing the pipe is an Arc
// so the cloning should be fast.
let config = STDIN_PIPE.get().unwrap().clone();
cx.wasi_ctx = Some(
WasiCtxBuilder::new()
.stdin(config)
.inherit_stdout()
.inherit_stderr()
.build_p1(),
);
}
cx.wasi_ctx.as_mut().unwrap()
})?;
Ok(linker)
Expand Down
Loading