aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-pcre/src
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-17 02:19:11 +0900
committernsfisis <nsfisis@gmail.com>2026-08-17 02:19:11 +0900
commit089215c1c26b4b09f697e3711416cbed0c53b0d3 (patch)
treef67acd31cb7f1249f7ad2ffaf8033caadf49c97b /crates/shirabe-pcre/src
parent1dfd1ae32b9b27573b9ee4439674091b792bcce0 (diff)
downloadphp-shirabe-089215c1c26b4b09f697e3711416cbed0c53b0d3.tar.gz
php-shirabe-089215c1c26b4b09f697e3711416cbed0c53b0d3.tar.zst
php-shirabe-089215c1c26b4b09f697e3711416cbed0c53b0d3.zip
refactor(preg): drop unused flags and offset of preg_match_all2()
Every caller reached preg_match_all2() through Preg::match_all5(), which always passed flags = PREG_UNMATCHED_AS_NULL and offset = 0. Inline those constants and make match_all5() private, since the two public wrappers are its only callers. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-pcre/src')
-rw-r--r--crates/shirabe-pcre/src/preg.rs21
1 files changed, 5 insertions, 16 deletions
diff --git a/crates/shirabe-pcre/src/preg.rs b/crates/shirabe-pcre/src/preg.rs
index e197c874..95697e83 100644
--- a/crates/shirabe-pcre/src/preg.rs
+++ b/crates/shirabe-pcre/src/preg.rs
@@ -57,7 +57,7 @@ impl Preg {
}
pub fn match_all(pattern: impl PregPattern, subject: &str) -> usize {
- Self::match_all5(pattern, subject, None, 0, 0)
+ Self::match_all5(pattern, subject, None)
}
pub fn match_all3(
@@ -65,27 +65,16 @@ impl Preg {
subject: &str,
matches: Option<&mut IndexMap<CaptureKey, Vec<String>>>,
) -> usize {
- Self::match_all5(pattern, subject, matches, 0, 0)
+ Self::match_all5(pattern, subject, matches)
}
- pub fn match_all5(
+ fn match_all5(
pattern: impl PregPattern,
subject: &str,
matches: Option<&mut IndexMap<CaptureKey, Vec<String>>>,
- flags: i64,
- offset: usize,
) -> usize {
- Self::check_offset_capture(flags, "matchAllWithOffsets");
- Self::check_set_order(flags);
-
let mut internal: IndexMap<CaptureKey, Vec<Option<String>>> = IndexMap::new();
- let result = preg_match_all2(
- pattern,
- subject,
- &mut internal,
- flags | PREG_UNMATCHED_AS_NULL,
- offset,
- );
+ let result = preg_match_all2(pattern, subject, &mut internal);
if let Some(out) = matches {
*out = null_to_empty_match_all(internal);
@@ -266,7 +255,7 @@ impl Preg {
subject: &str,
matches: Option<&mut IndexMap<CaptureKey, Vec<String>>>,
) -> bool {
- Self::match_all5(pattern, subject, matches, 0, 0) > 0
+ Self::match_all5(pattern, subject, matches) > 0
}
pub fn is_match_all_with_offsets3(