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/update_command.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/shirabe/src/command/update_command.rs') diff --git a/crates/shirabe/src/command/update_command.rs b/crates/shirabe/src/command/update_command.rs index dcfbc371..213ac248 100644 --- a/crates/shirabe/src/command/update_command.rs +++ b/crates/shirabe/src/command/update_command.rs @@ -29,8 +29,8 @@ use crate::util::HttpDownloader; use indexmap::IndexMap; use shirabe_php_shim::{ InvalidArgumentException, PhpMixed, RuntimeException, array_filter, array_intersect, - array_keys, array_merge_map, array_search_in_vec, impl_php_class, php_regex, preg_match, - preg_replace, strtolower, + array_keys, array_merge_map, array_search_in_vec, impl_php_class, php_regex, preg_is_match, + preg_match, preg_replace, strtolower, }; use shirabe_semver::Intervals; use shirabe_semver::constraint::MultiConstraint; @@ -115,7 +115,7 @@ impl UpdateCommand { let mut version_selector = self.create_version_selector(composer)?; for package in &installed_packages { if let Some(filter) = &filter - && preg_match(filter, &package.get_name()).is_none() + && !preg_is_match(filter, &package.get_name()) { continue; } @@ -378,7 +378,7 @@ impl Command for UpdateCommand { if !packages.is_empty() { let allowlist_packages_with_requirements: Vec = array_filter(&packages, |pkg: &String| -> bool { - preg_match(php_regex!(r"{\S+[ =:]\S+}"), pkg).is_some() + preg_is_match(php_regex!(r"{\S+[ =:]\S+}"), pkg) }); for (package, constraint) in self.format_requirements(allowlist_packages_with_requirements.clone())? -- cgit v1.3.1-4-g156e