diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2019-09-03 19:32:44 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2019-09-05 11:43:35 -0700 |
| commit | 0b7ba6ec54db24b676d376665692a49d0ecd603a (patch) | |
| tree | 25df682f7c109db23c0e59dacd72af3aa58610df /src/libstd/sys/cloudabi/shims/process.rs | |
| parent | 618768492f0c731fcb770dc2d178abe840846419 (diff) | |
| download | rust-0b7ba6ec54db24b676d376665692a49d0ecd603a.tar.gz rust-0b7ba6ec54db24b676d376665692a49d0ecd603a.zip | |
std: Improve downstream codegen in `Command::env`
This commit rejiggers the generics used in the implementation of
`Command::env` with the purpose of reducing the amount of codegen that
needs to happen in consumer crates, instead preferring to generate code
into libstd.
This was found when profiling the compile times of the `cc` crate where
the binary rlib produced had a lot of `BTreeMap` code compiled into it
but the crate doesn't actually use `BTreeMap`. It turns out that
`Command::env` is generic enough to codegen the entire implementation in
calling crates, but in this case there's no performance concern so it's
fine to compile the code into the standard library.
This change is done by removing the generic on the `CommandEnv` map
which is intended to handle case-insensitive variables on Windows.
Instead now a generic isn't used but rather a `use` statement defined
per-platform is used.
With this commit a debug build of `Command::new("foo").env("a", "b")`
drops from 21k lines of LLVM IR to 10k.
Diffstat (limited to 'src/libstd/sys/cloudabi/shims/process.rs')
| -rw-r--r-- | src/libstd/sys/cloudabi/shims/process.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libstd/sys/cloudabi/shims/process.rs b/src/libstd/sys/cloudabi/shims/process.rs index e719b362cbf..03a59d6d7c8 100644 --- a/src/libstd/sys/cloudabi/shims/process.rs +++ b/src/libstd/sys/cloudabi/shims/process.rs @@ -4,14 +4,16 @@ use crate::io; use crate::sys::fs::File; use crate::sys::pipe::AnonPipe; use crate::sys::{unsupported, Void}; -use crate::sys_common::process::{CommandEnv, DefaultEnvKey}; +use crate::sys_common::process::CommandEnv; + +pub use crate::ffi::OsString as EnvKey; //////////////////////////////////////////////////////////////////////////////// // Command //////////////////////////////////////////////////////////////////////////////// pub struct Command { - env: CommandEnv<DefaultEnvKey>, + env: CommandEnv, } // passed back to std::process with the pipes connected to the child, if any @@ -37,7 +39,7 @@ impl Command { pub fn arg(&mut self, _arg: &OsStr) {} - pub fn env_mut(&mut self) -> &mut CommandEnv<DefaultEnvKey> { + pub fn env_mut(&mut self) -> &mut CommandEnv { &mut self.env } |
