Skip to content

Commit

Permalink
Slight optimization in codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffcharles committed Dec 5, 2024
1 parent f576f4a commit 6fd094f
Showing 1 changed file with 12 additions and 10 deletions.
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

0 comments on commit 6fd094f

Please sign in to comment.