aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/repository/composer_repository.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/src/repository/composer_repository.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/src/repository/composer_repository.rs')
-rw-r--r--crates/shirabe/src/repository/composer_repository.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/shirabe/src/repository/composer_repository.rs b/crates/shirabe/src/repository/composer_repository.rs
index fbf9f767..79588fc5 100644
--- a/crates/shirabe/src/repository/composer_repository.rs
+++ b/crates/shirabe/src/repository/composer_repository.rs
@@ -43,7 +43,7 @@ use shirabe_php_shim::{
json_decode_assoc, parse_url, php_regex, preg_split, realpath, strtolower, strtr, urlencode,
var_export,
};
-use shirabe_php_shim::{Catch as _, preg_grep, preg_match, preg_replace};
+use shirabe_php_shim::{Catch as _, preg_grep, preg_is_match, preg_match, preg_replace};
use shirabe_semver::CompilingMatcher;
use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::MatchAllConstraint;
@@ -161,7 +161,7 @@ impl ComposerRepository {
.and_then(|v| v.as_string())
.unwrap_or("")
.to_string();
- if preg_match(php_regex!(r"{^[\w.]+\??://}"), &url_str).is_none() {
+ if !preg_is_match(php_regex!(r"{^[\w.]+\??://}"), &url_str) {
if let Some(local_file_path) = realpath(&url_str) {
// it is a local path, add file scheme
repo_config.insert(
@@ -2708,7 +2708,7 @@ impl ComposerRepository {
// url-encode $ signs in URLs as bad proxies choke on them
if let Some(pos) = filename.find('$')
&& pos > 0
- && preg_match(php_regex!(r"{^https?://}i"), &filename).is_some()
+ && preg_is_match(php_regex!(r"{^https?://}i"), &filename)
{
filename = format!("{}%24{}", &filename[..pos], &filename[pos + 1..]);
}
@@ -3307,7 +3307,7 @@ impl ComposerRepository {
if let Some(ref patterns) = self.available_package_patterns {
for provider_regex in patterns.iter() {
- if preg_match(provider_regex, name).is_some() {
+ if preg_is_match(provider_regex, name) {
return Ok(true);
}
}