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/composer_repository.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'crates/shirabe/src/repository/composer_repository.rs') diff --git a/crates/shirabe/src/repository/composer_repository.rs b/crates/shirabe/src/repository/composer_repository.rs index 833be0af..59e1d520 100644 --- a/crates/shirabe/src/repository/composer_repository.rs +++ b/crates/shirabe/src/repository/composer_repository.rs @@ -40,8 +40,8 @@ use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_metadata_minifier::MetadataMinifier; use shirabe_php_shim::{ InvalidArgumentException, LogicException, PHP_EOL, PhpMixed, RuntimeException, - UnexpectedValueException, extension_loaded, hash, http_build_query, in_array_strict, - json_decode, parse_url_all, php_regex, realpath, strtolower, strtr, urlencode, var_export, + UnexpectedValueException, extension_loaded, hash, http_build_query, json_decode, parse_url_all, + php_regex, realpath, strtolower, strtr, urlencode, var_export, }; use shirabe_semver::CompilingMatcher; use shirabe_semver::constraint::AnyConstraint; @@ -1441,13 +1441,7 @@ impl ComposerRepository { if let Some(te) = e.downcast_ref::() { let status_code = te.get_status_code(); if self.lazy_providers_url.is_some() - && in_array_strict( - match status_code { - Some(c) => PhpMixed::Int(c), - None => PhpMixed::Null, - }, - &[PhpMixed::Int(404), PhpMixed::Int(499)], - ) + && matches!(status_code, Some(404 | 499)) { let mut p: IndexMap = IndexMap::new(); p.insert("packages".to_string(), PhpMixed::Array(IndexMap::new())); -- cgit v1.3.1