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/package/alias_package.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'crates/shirabe/src/package/alias_package.rs') diff --git a/crates/shirabe/src/package/alias_package.rs b/crates/shirabe/src/package/alias_package.rs index fb775130..088cd6ab 100644 --- a/crates/shirabe/src/package/alias_package.rs +++ b/crates/shirabe/src/package/alias_package.rs @@ -11,7 +11,7 @@ use crate::repository::RepositoryInterfaceWeakHandle; use chrono::{DateTime, Utc}; use indexmap::IndexMap; use indexmap::IndexSet; -use shirabe_php_shim::{LogicException, PhpMixed, in_array_strict}; +use shirabe_php_shim::{LogicException, PhpMixed}; use shirabe_semver::constraint::SimpleConstraint; #[derive(Debug, Clone)] @@ -131,13 +131,9 @@ impl AliasPackage { pretty_version = self.alias_of.get_pretty_version(); } - if in_array_strict( - link_type.to_string(), - &[ - PhpMixed::String(Link::TYPE_CONFLICT.to_string()), - PhpMixed::String(Link::TYPE_PROVIDE.to_string()), - PhpMixed::String(Link::TYPE_REPLACE.to_string()), - ], + if matches!( + link_type, + Link::TYPE_CONFLICT | Link::TYPE_PROVIDE | Link::TYPE_REPLACE ) { let mut new_links: Vec = vec![]; for link in links.values() { -- cgit v1.3.1