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/util/config_validator.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'crates/shirabe/src/util/config_validator.rs') diff --git a/crates/shirabe/src/util/config_validator.rs b/crates/shirabe/src/util/config_validator.rs index e9282a9f..f8018fe5 100644 --- a/crates/shirabe/src/util/config_validator.rs +++ b/crates/shirabe/src/util/config_validator.rs @@ -10,7 +10,7 @@ use crate::package::loader::ValidatingArrayLoader; use indexmap::IndexMap; use serde::de::Error as _; use shirabe_php_shim::Catch as _; -use shirabe_php_shim::{PhpMixed, php_regex, preg_match, preg_replace}; +use shirabe_php_shim::{PhpMixed, php_regex, preg_is_match, preg_replace}; use shirabe_spdx_licenses::SpdxLicenses; #[derive(Debug)] @@ -117,16 +117,13 @@ impl ConfigValidator { for license in &licenses { let spdx_license = license_validator.get_license_by_identifier(license); if spdx_license.is_some_and(|l| l.is_deprecated_license_id) { - if preg_match(php_regex!(r"{^[AL]?GPL-[123](\.[01])?\+$}i"), license).is_some() - { + if preg_is_match(php_regex!(r"{^[AL]?GPL-[123](\.[01])?\+$}i"), license) { warnings.push(format!( "License \"{}\" is a deprecated SPDX license identifier, use \"{}-or-later\" instead", license, license.replace('+', "") )); - } else if preg_match(php_regex!(r"{^[AL]?GPL-[123](\.[01])?$}i"), license) - .is_some() - { + } else if preg_is_match(php_regex!(r"{^[AL]?GPL-[123](\.[01])?$}i"), license) { warnings.push(format!( "License \"{}\" is a deprecated SPDX license identifier, use \"{}-only\" or \"{}-or-later\" instead", license, license, license @@ -147,7 +144,7 @@ impl ConfigValidator { if let Some(PhpMixed::String(name)) = manifest.get("name") && !name.is_empty() - && preg_match(php_regex!(r"{[A-Z]}"), name).is_some() + && preg_is_match(php_regex!(r"{[A-Z]}"), name) { let suggest_name = preg_replace( php_regex!(r"{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}"), @@ -224,7 +221,7 @@ impl ConfigValidator { packages.extend(require_dev); for (package, version) in &packages { if let PhpMixed::String(version_str) = version - && preg_match(php_regex!(r"{#}"), version_str).is_some() + && preg_is_match(php_regex!(r"{#}"), version_str) { warnings.push(format!( "The package \"{}\" is pointing to a commit-ref, this is bad practice and can cause unforeseen issues.", -- cgit v1.3.1-4-g156e