From 2886b20971a77d84cadc1f44b72e1373a7df9993 Mon Sep 17 00:00:00 2001 From: Charlie Le <20309750+CharlieQLe@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:26:14 -0500 Subject: [PATCH] Do not create a new Vec in async_process for flatpak env args --- src/async_process.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/async_process.rs b/src/async_process.rs index c3cfc76..53ab9f5 100644 --- a/src/async_process.rs +++ b/src/async_process.rs @@ -18,15 +18,12 @@ pub async fn async_process, T: AsRef>( ) -> anyhow::Result { let mut command: Command; if *IS_FLATPAK && host_spawn { - let mut flatpak_env = vec![]; - for (key, value) in env.unwrap_or_default() { - flatpak_env.push(format!("--env={}={}", key, value)); - } command = Command::new("flatpak-spawn"); - command.arg("--host") - .args(flatpak_env) - .arg(cmd) - .args(args.unwrap_or_default()); + command.arg("--host"); + for (key, value) in env.unwrap_or_default() { + command.arg(format!("--env={}={}", key, value)); + } + command.arg(cmd).args(args.unwrap_or_default()); } else { command = Command::new(cmd); command.args(args.unwrap_or_default()).envs(env.unwrap_or_default());