diff options
author | Matt Mastracci <matthew@mastracci.com> | 2024-03-22 14:03:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-22 14:03:56 -0700 |
commit | 86cdf3703399367836c89accba3756437d820bb0 (patch) | |
tree | 986ab6c88e0a65ffaadb164eab94d44c0ff497b1 /cli/standalone/binary.rs | |
parent | 08ec6e5831478f6d15188e91d9a8e3c00d80c1ed (diff) |
perf(cli): use args_os (#23039)
Extracted from #22718
Diffstat (limited to 'cli/standalone/binary.rs')
-rw-r--r-- | cli/standalone/binary.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/cli/standalone/binary.rs b/cli/standalone/binary.rs index 2b334ec46..a3a12f5e2 100644 --- a/cli/standalone/binary.rs +++ b/cli/standalone/binary.rs @@ -2,6 +2,7 @@ use std::collections::BTreeMap; use std::env::current_exe; +use std::ffi::OsString; use std::fs; use std::future::Future; use std::io::Read; @@ -239,7 +240,7 @@ pub fn is_standalone_binary(exe_path: &Path) -> bool { /// the bundle is executed. If not, this function exits with `Ok(None)`. pub fn extract_standalone( exe_path: &Path, - cli_args: Vec<String>, + cli_args: Vec<OsString>, ) -> Result< Option<impl Future<Output = Result<(Metadata, eszip::EszipV2), AnyError>>>, AnyError, @@ -281,7 +282,10 @@ pub fn extract_standalone( .context("Failed to read metadata from the current executable")?; let mut metadata: Metadata = serde_json::from_str(&metadata).unwrap(); - metadata.argv.append(&mut cli_args[1..].to_vec()); + metadata.argv.reserve(cli_args.len() - 1); + for arg in cli_args.into_iter().skip(1) { + metadata.argv.push(arg.into_string().unwrap()); + } Ok((metadata, eszip)) })) |