diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-17 02:19:11 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-17 02:19:11 +0900 |
| commit | 089215c1c26b4b09f697e3711416cbed0c53b0d3 (patch) | |
| tree | f67acd31cb7f1249f7ad2ffaf8033caadf49c97b /crates/shirabe-php-shim/src | |
| parent | 1dfd1ae32b9b27573b9ee4439674091b792bcce0 (diff) | |
| download | php-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-php-shim/src')
| -rw-r--r-- | crates/shirabe-php-shim/src/preg.rs | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/crates/shirabe-php-shim/src/preg.rs b/crates/shirabe-php-shim/src/preg.rs index 727fc149..42a3ecec 100644 --- a/crates/shirabe-php-shim/src/preg.rs +++ b/crates/shirabe-php-shim/src/preg.rs @@ -122,27 +122,20 @@ pub fn preg_match_all2( pattern: impl PregPattern, subject: &str, matches: &mut indexmap::IndexMap<CaptureKey, Vec<Option<String>>>, - flags: i64, - offset: usize, ) -> usize { let __resolved = pattern.resolve(); let (re, _anchored) = __resolved.parts(); - let unmatched_as_null = flags & PREG_UNMATCHED_AS_NULL != 0; let group_count = re.captures_len(); let names: Vec<Option<&str>> = re.capture_names().collect(); // PREG_PATTERN_ORDER: one column per group, one row per match occurrence. let mut groups: Vec<Vec<Option<String>>> = vec![Vec::new(); group_count]; let mut count = 0; - for caps in re.captures_iter(&subject[offset..]) { + for caps in re.captures_iter(subject) { count += 1; for (g, column) in groups.iter_mut().enumerate() { let value = caps.get(g).map(|m| m.as_str().to_string()); - column.push(if unmatched_as_null { - value - } else { - Some(value.unwrap_or_default()) - }); + column.push(value); } } |
