aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-class-map-generator/src/class_map_generator.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-18 01:57:02 +0900
committernsfisis <nsfisis@gmail.com>2026-08-18 01:57:02 +0900
commitfed0a6e7ac361af9b963c1f62411b1a85478230c (patch)
tree5cde64a24845c761890fbcbe05e0d702f1ec8df7 /crates/shirabe-class-map-generator/src/class_map_generator.rs
parente093b2be1c333e67c96aebb0a5291bea9ae3d6db (diff)
downloadphp-shirabe-fed0a6e7ac361af9b963c1f62411b1a85478230c.tar.gz
php-shirabe-fed0a6e7ac361af9b963c1f62411b1a85478230c.tar.zst
php-shirabe-fed0a6e7ac361af9b963c1f62411b1a85478230c.zip
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-class-map-generator/src/class_map_generator.rs')
-rw-r--r--crates/shirabe-class-map-generator/src/class_map_generator.rs13
1 files changed, 6 insertions, 7 deletions
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;
}
}