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/repository/vcs_repository.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'crates/shirabe/src/repository/vcs_repository.rs') diff --git a/crates/shirabe/src/repository/vcs_repository.rs b/crates/shirabe/src/repository/vcs_repository.rs index c8790f81..521d7aea 100644 --- a/crates/shirabe/src/repository/vcs_repository.rs +++ b/crates/shirabe/src/repository/vcs_repository.rs @@ -29,7 +29,7 @@ use crate::util::Url; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::Preg; use shirabe_php_shim::{ - InvalidArgumentException, PhpClass, PhpMixed, in_array_strict, php_regex, str_replace, strpos, + InvalidArgumentException, PhpClass, PhpMixed, php_regex, str_replace, strpos, }; use shirabe_semver::constraint::SimpleConstraint; @@ -1030,10 +1030,7 @@ impl VcsRepository { } fn should_rethrow_transport_exception(&self, e: &TransportException) -> bool { - in_array_strict( - e.get_code(), - &[PhpMixed::Int(401), PhpMixed::Int(403), PhpMixed::Int(429)], - ) || e.get_code() >= 500 + matches!(e.get_code(), 401 | 403 | 429) || e.get_code() >= 500 } } -- cgit v1.3.1