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/downloader/svn_downloader.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'crates/shirabe/src/downloader/svn_downloader.rs') diff --git a/crates/shirabe/src/downloader/svn_downloader.rs b/crates/shirabe/src/downloader/svn_downloader.rs index 42152eb3..93b860f0 100644 --- a/crates/shirabe/src/downloader/svn_downloader.rs +++ b/crates/shirabe/src/downloader/svn_downloader.rs @@ -16,8 +16,8 @@ use crate::util::ProcessExecutor; use crate::util::Svn as SvnUtil; use indexmap::IndexMap; use shirabe_php_shim::{ - CmpOp, PhpMixed, RuntimeException, impl_php_class, is_dir, php_regex, preg_match, preg_replace, - preg_split, version_compare, + CmpOp, PhpMixed, RuntimeException, impl_php_class, is_dir, php_regex, preg_is_match, + preg_match, preg_replace, preg_split, version_compare, }; #[derive(Debug)] @@ -353,8 +353,8 @@ impl VcsDownloader for SvnDownloader { to_reference: &str, path: &str, ) -> anyhow::Result { - if preg_match(php_regex!(r"{@(\d+)$}"), from_reference).is_some() - && preg_match(php_regex!(r"{@(\d+)$}"), to_reference).is_some() + if preg_is_match(php_regex!(r"{@(\d+)$}"), from_reference) + && preg_is_match(php_regex!(r"{@(\d+)$}"), to_reference) { // retrieve the svn base url from the checkout folder let command = vec![ @@ -452,13 +452,11 @@ impl ChangeReportInterface for SvnDownloader { Some(path), ); - Ok( - if preg_match(php_regex!("{^ *[^X ] +}m"), &output).is_some() { - Some(output) - } else { - None - }, - ) + Ok(if preg_is_match(php_regex!("{^ *[^X ] +}m"), &output) { + Some(output) + } else { + None + }) } } -- cgit v1.3.1-4-g156e