From 86cdf3703399367836c89accba3756437d820bb0 Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Fri, 22 Mar 2024 14:03:56 -0700 Subject: perf(cli): use args_os (#23039) Extracted from #22718 --- cli/standalone/binary.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'cli/standalone') 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, + cli_args: Vec, ) -> Result< Option>>, 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)) })) -- cgit v1.2.3