Skip to content

Commit 68426f1

Browse files
authored
perf(wasi): avoid extra allocations in inherit_env/args (#12431)
1 parent 7ee620a commit 68426f1

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

crates/wasi/src/ctx.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ impl WasiCtxBuilder {
217217
/// This will use [`envs`](WasiCtxBuilder::envs) to append all host-defined
218218
/// environment variables.
219219
pub fn inherit_env(&mut self) -> &mut Self {
220-
self.envs(&std::env::vars().collect::<Vec<(String, String)>>())
220+
self.cli.environment.extend(std::env::vars());
221+
self
221222
}
222223

223224
/// Appends a list of arguments to the argument array to pass to wasm.
@@ -237,7 +238,8 @@ impl WasiCtxBuilder {
237238
/// Appends all host process arguments to the list of arguments to get
238239
/// passed to wasm.
239240
pub fn inherit_args(&mut self) -> &mut Self {
240-
self.args(&std::env::args().collect::<Vec<String>>())
241+
self.cli.arguments.extend(std::env::args());
242+
self
241243
}
242244

243245
/// Configures a "preopened directory" to be available to WebAssembly.

0 commit comments

Comments
 (0)