diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-21 17:02:52 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-21 17:12:37 +0900 |
| commit | 84fe6ac6977f15cbec85cbc9f773567742a7fb87 (patch) | |
| tree | 5701e7c980585dd404471ab9fa53e98a0ba601ab /crates/shirabe/src/config.rs | |
| parent | 12a7756588a20f1351e6976f0c009de5992514a9 (diff) | |
| download | php-shirabe-84fe6ac6977f15cbec85cbc9f773567742a7fb87.tar.gz php-shirabe-84fe6ac6977f15cbec85cbc9f773567742a7fb87.tar.zst php-shirabe-84fe6ac6977f15cbec85cbc9f773567742a7fb87.zip | |
refactor(math): use method-style max/min/clamp over std::cmp
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/config.rs')
| -rw-r--r-- | crates/shirabe/src/config.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/crates/shirabe/src/config.rs b/crates/shirabe/src/config.rs index 2c39db5..b65961e 100644 --- a/crates/shirabe/src/config.rs +++ b/crates/shirabe/src/config.rs @@ -14,8 +14,7 @@ use shirabe_php_shim::{ E_USER_DEPRECATED, FILTER_VALIDATE_URL, PHP_URL_HOST, PHP_URL_SCHEME, PhpMixed, RuntimeException, array_key_exists, array_merge, array_reverse, array_search_mixed, array_unique, current, empty, filter_var, implode, in_array, is_array, is_int, is_string, key, - max, parse_url, php_to_string, reset, rtrim, strtolower, strtoupper, strtr, substr, - trigger_error, + parse_url, php_to_string, reset, rtrim, strtolower, strtoupper, strtr, substr, trigger_error, }; use std::cell::RefCell; @@ -587,7 +586,7 @@ impl Config { } else { val.clone() }; - return Ok(PhpMixed::Int(max(0, raw.as_int().unwrap_or(0)))); + return Ok(PhpMixed::Int(raw.as_int().unwrap_or(0).max(0))); } let raw_val = if matches!(val, PhpMixed::Bool(false)) { @@ -647,10 +646,13 @@ impl Config { } // ints without env var support - "cache-ttl" => Ok(PhpMixed::Int(max( - 0, - self.config.get(key).and_then(|v| v.as_int()).unwrap_or(0), - ))), + "cache-ttl" => Ok(PhpMixed::Int( + self.config + .get(key) + .and_then(|v| v.as_int()) + .unwrap_or(0) + .max(0), + )), // numbers with kb/mb/gb support, without env var support "cache-files-maxsize" => { @@ -697,7 +699,7 @@ impl Config { } } - Ok(PhpMixed::Int(max(0, size as i64))) + Ok(PhpMixed::Int((size as i64).max(0))) } // special cases below @@ -706,7 +708,7 @@ impl Config { if let Some(v) = v && !v.is_null() { - return Ok(PhpMixed::Int(max(0, v.as_int().unwrap_or(0)))); + return Ok(PhpMixed::Int(v.as_int().unwrap_or(0).max(0))); } self.get_with_flags("cache-ttl", 0) |
