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-class-map-generator/src/class_map_generator.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'crates/shirabe-class-map-generator') diff --git a/crates/shirabe-class-map-generator/src/class_map_generator.rs b/crates/shirabe-class-map-generator/src/class_map_generator.rs index 57a21508..9fa37246 100644 --- a/crates/shirabe-class-map-generator/src/class_map_generator.rs +++ b/crates/shirabe-class-map-generator/src/class_map_generator.rs @@ -73,14 +73,7 @@ impl ClassMapGenerator { namespace: Option, excluded_dirs: Vec, ) -> anyhow::Result<()> { - if !in_array_strict( - autoload_type.to_string(), - &[ - PhpMixed::String("psr-0".to_string()), - PhpMixed::String("psr-4".to_string()), - PhpMixed::String("classmap".to_string()), - ], - ) { + if !matches!(autoload_type, "psr-0" | "psr-4" | "classmap") { return Err(anyhow::anyhow!(InvalidArgumentException { message: "$autoloadType must be one of: \"psr-0\", \"psr-4\" or \"classmap\"" .to_string(), -- cgit v1.3.1