From fed0a6e7ac361af9b963c1f62411b1a85478230c Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 18 Aug 2026 01:57:02 +0900 Subject: refactor(preg): add preg_is_match for existence-only call sites The capture groups were discarded at 162 of the preg_match call sites, which only tested the Option. They now call preg_is_match, which lets the regex engine skip capture tracking. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe/src/command/config_command.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'crates/shirabe/src/command/config_command.rs') diff --git a/crates/shirabe/src/command/config_command.rs b/crates/shirabe/src/command/config_command.rs index f1eb14b0..0788d694 100644 --- a/crates/shirabe/src/command/config_command.rs +++ b/crates/shirabe/src/command/config_command.rs @@ -22,8 +22,8 @@ use shirabe_php_shim::{ InvalidArgumentException, PhpMixed, RuntimeException, array_is_list, array_merge, escapeshellcmd, exec, explode, file_exists, impl_php_class, implode, in_array_loose, in_array_strict, is_array, is_bool, is_dir, is_numeric, is_object, is_string, json_encode, - php_regex, preg_match, preg_replace, str_replace, strpos, strtolower, system, touch, - var_export, + php_regex, preg_is_match, preg_match, preg_replace, str_replace, strpos, strtolower, system, + touch, var_export, }; use shirabe_semver::VersionParser; use shirabe_symfony_console::command::Command; @@ -1449,7 +1449,7 @@ impl Command for ConfigCommand { } // Check if the header is in correct "Name: Value" format - if preg_match(php_regex!("/^[^:]+:\\s*.+$/"), header).is_none() { + if !preg_is_match(php_regex!("/^[^:]+:\\s*.+$/"), header) { return Err(RuntimeException::new(format!( "Header \"{}\" is not in \"Header-Name: Header-Value\" format", header @@ -1735,13 +1735,10 @@ fn build_unique_config_values() -> IndexMap "cache-files-maxsize".to_string(), ( Box::new(|val| { - PhpMixed::Bool( - preg_match( - php_regex!("/^\\s*([0-9.]+)\\s*(?:([kmg])(?:i?b)?)?\\s*$/i"), - val.as_string().unwrap_or(""), - ) - .is_some(), - ) + PhpMixed::Bool(preg_is_match( + php_regex!("/^\\s*([0-9.]+)\\s*(?:([kmg])(?:i?b)?)?\\s*$/i"), + val.as_string().unwrap_or(""), + )) }), Box::new(|val| val.clone()), ), -- cgit v1.3.1-4-g156e