Skip to content

Commit

Permalink
Slight optimization in codegen (#856)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffcharles authored Dec 5, 2024
1 parent f576f4a commit e736396
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 e736396

Please sign in to comment.