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/util/http/curl_downloader.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'crates/shirabe/src/util/http') diff --git a/crates/shirabe/src/util/http/curl_downloader.rs b/crates/shirabe/src/util/http/curl_downloader.rs index 64ff42a6..604dae77 100644 --- a/crates/shirabe/src/util/http/curl_downloader.rs +++ b/crates/shirabe/src/util/http/curl_downloader.rs @@ -413,13 +413,7 @@ impl CurlDownloader { .and_then(|v| v.as_int()) .unwrap_or(0); if Self::method_is_get(options) - && in_array_strict( - status_code, - &[423, 425, 500, 502, 503, 504, 507, 510] - .iter() - .map(|c| PhpMixed::Int(*c)) - .collect::>(), - ) + && matches!(status_code, 423 | 425 | 500 | 502 | 503 | 504 | 507 | 510) && retries < self.max_retries { self.io.write_error3( @@ -820,16 +814,14 @@ impl CurlDownloader { } let mut details = String::new(); - if in_array_strict( + if matches!( response .inner .get_header("content-type") .unwrap_or_default() - .to_lowercase(), - &[ - PhpMixed::String("application/json".to_string()), - PhpMixed::String("application/json; charset=utf-8".to_string()), - ], + .to_lowercase() + .as_str(), + "application/json" | "application/json; charset=utf-8" ) { let body = response.inner.get_body().unwrap_or(""); details = format!( -- cgit v1.3.1