From 81b9fc9d92bb74aa8428ae4db39bd84e8c16095c Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 20 Jun 2026 18:34:54 +0900 Subject: refactor(php-shim): drop Box wrapping from PhpMixed List/Array The List and Array variants of PhpMixed boxed their elements unnecessarily. Store PhpMixed values directly and update all callers accordingly. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/src/util/process_executor.rs | 34 ++++++++++------------------- 1 file changed, 11 insertions(+), 23 deletions(-) (limited to 'crates/shirabe/src/util/process_executor.rs') diff --git a/crates/shirabe/src/util/process_executor.rs b/crates/shirabe/src/util/process_executor.rs index ca31290..2bdf065 100644 --- a/crates/shirabe/src/util/process_executor.rs +++ b/crates/shirabe/src/util/process_executor.rs @@ -149,7 +149,7 @@ impl ProcessExecutor { let cmd = PhpMixed::List( command .iter() - .map(|s| Box::new(PhpMixed::String(s.clone()))) + .map(|s| PhpMixed::String(s.clone())) .collect(), ); let mut buf = PhpMixed::String(String::new()); @@ -352,9 +352,9 @@ impl ProcessExecutor { git_env.insert("GIT_DIR".to_string(), cwd.unwrap().to_string()); self.run_process( PhpMixed::List(vec![ - Box::new(PhpMixed::String("git".to_string())), - Box::new(PhpMixed::String("config".to_string())), - Box::new(PhpMixed::String("safe.bareRepository".to_string())), + PhpMixed::String("git".to_string()), + PhpMixed::String("config".to_string()), + PhpMixed::String("safe.bareRepository".to_string()), ]), cwd, Some(git_env.clone()), @@ -677,7 +677,7 @@ impl ProcessExecutor { } else if let PhpMixed::List(list) = command { let parts: Vec = array_map( |v| Self::escape(v.as_string().unwrap_or("")), - &list.iter().map(|b| (**b).clone()).collect::>(), + &list.iter().cloned().collect::>(), ); implode(" ", &parts) } else { @@ -810,7 +810,7 @@ impl ProcessExecutor { &PhpMixed::List( Self::BUILTIN_CMD_COMMANDS .iter() - .map(|s| Box::new(PhpMixed::String(s.to_string()))) + .map(|s| PhpMixed::String(s.to_string())) .collect(), ), true, @@ -870,21 +870,13 @@ impl IntoExecCommand for &String { impl IntoExecCommand for Vec { fn into_exec_command(self) -> PhpMixed { - PhpMixed::List( - self.into_iter() - .map(|s| Box::new(PhpMixed::String(s))) - .collect(), - ) + PhpMixed::List(self.into_iter().map(PhpMixed::String).collect()) } } impl IntoExecCommand for &Vec { fn into_exec_command(self) -> PhpMixed { - PhpMixed::List( - self.iter() - .map(|s| Box::new(PhpMixed::String(s.clone()))) - .collect(), - ) + PhpMixed::List(self.iter().map(|s| PhpMixed::String(s.clone())).collect()) } } @@ -892,7 +884,7 @@ impl IntoExecCommand for &[&str; N] { fn into_exec_command(self) -> PhpMixed { PhpMixed::List( self.iter() - .map(|s| Box::new(PhpMixed::String(s.to_string()))) + .map(|s| PhpMixed::String(s.to_string())) .collect(), ) } @@ -902,7 +894,7 @@ impl IntoExecCommand for &[&str] { fn into_exec_command(self) -> PhpMixed { PhpMixed::List( self.iter() - .map(|s| Box::new(PhpMixed::String(s.to_string()))) + .map(|s| PhpMixed::String(s.to_string())) .collect(), ) } @@ -910,11 +902,7 @@ impl IntoExecCommand for &[&str] { impl IntoExecCommand for &[String] { fn into_exec_command(self) -> PhpMixed { - PhpMixed::List( - self.iter() - .map(|s| Box::new(PhpMixed::String(s.clone()))) - .collect(), - ) + PhpMixed::List(self.iter().map(|s| PhpMixed::String(s.clone())).collect()) } } -- cgit v1.3.1