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) --- .../shirabe-class-map-generator/src/class_map_generator.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'crates/shirabe-class-map-generator/src/class_map_generator.rs') diff --git a/crates/shirabe-class-map-generator/src/class_map_generator.rs b/crates/shirabe-class-map-generator/src/class_map_generator.rs index da2f62c5..254e3a3f 100644 --- a/crates/shirabe-class-map-generator/src/class_map_generator.rs +++ b/crates/shirabe-class-map-generator/src/class_map_generator.rs @@ -5,9 +5,9 @@ use crate::file_list::FileList; use crate::php_file_parser::PhpFileParser; use shirabe_php_shim::{ InvalidArgumentException, LogicException, PATHINFO_EXTENSION, RuntimeException, explode, - getcwd, implode, is_dir, is_file, pathinfo, php_regex, preg_match, preg_quote, preg_replace, - preg_replace_callback, realpath, str_replace, stream_get_wrappers, strlen, strpos, strrpos, - strtr, substr, + getcwd, implode, is_dir, is_file, pathinfo, php_regex, preg_is_match, preg_match, preg_quote, + preg_replace, preg_replace_callback, realpath, str_replace, stream_get_wrappers, strlen, + strpos, strrpos, strtr, substr, }; use shirabe_symfony_finder::Finder; use std::path::PathBuf; @@ -134,8 +134,7 @@ impl ClassMapGenerator { continue; } - let is_stream_wrapper_path = - preg_match(&self.stream_wrappers_regex, &file_path).is_some(); + let is_stream_wrapper_path = preg_is_match(&self.stream_wrappers_regex, &file_path); if !Self::is_absolute_path(&file_path) && !is_stream_wrapper_path { file_path = format!("{}/{}", cwd, file_path); file_path = Self::normalize_path(&file_path); @@ -183,11 +182,11 @@ impl ClassMapGenerator { // check the realpath of the file against the excluded paths as the path might be a symlink and the excluded path is realpath'd so symlink are resolved if let Some(ref excluded) = excluded { - if preg_match(excluded, &strtr(&real_path, "\\", "/")).is_some() { + if preg_is_match(excluded, &strtr(&real_path, "\\", "/")) { continue; } // check non-realpath of file for directories symlink in project dir - if preg_match(excluded, &strtr(&file_path, "\\", "/")).is_some() { + if preg_is_match(excluded, &strtr(&file_path, "\\", "/")) { continue; } } -- cgit v1.3.1-4-g156e