aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/downloader
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-06 06:36:42 +0900
committernsfisis <nsfisis@gmail.com>2026-08-06 06:36:42 +0900
commit70e463708b461efd61a611061cfee0539d28645a (patch)
tree267066f1a6ac872d256de99a4ffafb1adf31f311 /crates/shirabe/src/downloader
parent791ef1cd465597ff43dab4216c4b00e9e4160da8 (diff)
downloadphp-shirabe-70e463708b461efd61a611061cfee0539d28645a.tar.gz
php-shirabe-70e463708b461efd61a611061cfee0539d28645a.tar.zst
php-shirabe-70e463708b461efd61a611061cfee0539d28645a.zip
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/downloader')
-rw-r--r--crates/shirabe/src/downloader/file_downloader.rs15
1 files changed, 3 insertions, 12 deletions
diff --git a/crates/shirabe/src/downloader/file_downloader.rs b/crates/shirabe/src/downloader/file_downloader.rs
index c6ee3a20..c5dfc5f7 100644
--- a/crates/shirabe/src/downloader/file_downloader.rs
+++ b/crates/shirabe/src/downloader/file_downloader.rs
@@ -28,8 +28,8 @@ use indexmap::IndexMap;
use shirabe_php_shim::{
DIRECTORY_SEPARATOR, InvalidArgumentException, PATHINFO_BASENAME, PATHINFO_EXTENSION,
PHP_URL_PATH, PhpMixed, RuntimeException, UnexpectedValueException, array_search, file_exists,
- filesize, get_class, hash, hash_file, in_array_strict, is_dir, is_executable, parse_url,
- pathinfo, realpath, rtrim, spl_object_hash, strlen, strpos, strtr, trim, umask, usleep,
+ filesize, get_class, hash, hash_file, is_dir, is_executable, parse_url, pathinfo, realpath,
+ rtrim, spl_object_hash, strlen, strpos, strtr, trim, umask, usleep,
};
use std::sync::{LazyLock, Mutex};
@@ -338,16 +338,7 @@ impl DownloaderInterface for FileDownloader {
if let Some(te) = e.downcast_ref::<TransportException>() {
// if we got an http response with a proper code, then requesting again will probably not help, abort
- if 0 != te.get_code()
- && !in_array_strict(
- te.get_code(),
- &[
- PhpMixed::Int(500),
- PhpMixed::Int(502),
- PhpMixed::Int(503),
- PhpMixed::Int(504),
- ],
- )
+ if 0 != te.get_code() && !matches!(te.get_code(), 500 | 502 | 503 | 504)
{
retries = 0;
}