From 70e463708b461efd61a611061cfee0539d28645a Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 6 Aug 2026 06:36:42 +0900 Subject: refactor: replace literal-list in_array_strict with matches! Call sites whose haystack was an inline array of literals (or a local built solely to feed one) had to wrap both sides in PhpMixed just to compare, allocating a String per element on every call. matches! does the same test against the underlying &str/i64/Option directly, so the PhpMixed round trip and its .to_string()/.clone()/.iter().map() conversions are gone. Sites whose haystack is a runtime value or a named constant array are left on in_array_strict: inlining a named constant would duplicate its contents at the call site. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe/src/command/update_command.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'crates/shirabe/src/command/update_command.rs') diff --git a/crates/shirabe/src/command/update_command.rs b/crates/shirabe/src/command/update_command.rs index e9bf34a9..1885e8eb 100644 --- a/crates/shirabe/src/command/update_command.rs +++ b/crates/shirabe/src/command/update_command.rs @@ -34,8 +34,7 @@ use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{ InvalidArgumentException, PhpMixed, RuntimeException, array_filter, array_intersect, - array_keys, array_merge_map, array_search_in_vec, impl_php_class, in_array_strict, php_regex, - strtolower, + array_keys, array_merge_map, array_search_in_vec, impl_php_class, php_regex, strtolower, }; use shirabe_semver::Intervals; use shirabe_semver::constraint::MultiConstraint; @@ -334,14 +333,7 @@ impl Command for UpdateCommand { // the arguments lock/nothing/mirrors are not package names but trigger a mirror update instead // they are further mutually exclusive with listing actual package names let filtered_packages: Vec = array_filter(&packages, |package: &String| -> bool { - !in_array_strict( - package.clone(), - &[ - PhpMixed::String("lock".to_string()), - PhpMixed::String("nothing".to_string()), - PhpMixed::String("mirrors".to_string()), - ], - ) + !matches!(package.as_str(), "lock" | "nothing" | "mirrors") }); let update_mirrors = input .borrow() -- cgit v1.3.1