From fcc6ee5a13cd2e2b27fff66dcfc7e9e1f062a653 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 17 Aug 2026 02:41:21 +0900 Subject: refactor(preg): drop unused args of preg_match_all_offset_capture2() The sole caller, Preg::match_all_with_offsets5(), always passed flags=0 and offset=0, so PREG_UNMATCHED_AS_NULL is now unconditional and the subject is scanned from the beginning. That method is only reached from Preg::match_all_with_offsets(), so it is no longer public either. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe-php-shim/src/preg.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'crates/shirabe-php-shim') diff --git a/crates/shirabe-php-shim/src/preg.rs b/crates/shirabe-php-shim/src/preg.rs index 42a3ecec..40eb25fb 100644 --- a/crates/shirabe-php-shim/src/preg.rs +++ b/crates/shirabe-php-shim/src/preg.rs @@ -200,24 +200,20 @@ pub fn preg_match_all_offset_capture2( pattern: impl PregPattern, subject: &str, matches: &mut indexmap::IndexMap, i64)>>, - 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> = re.capture_names().collect(); let mut groups: Vec, i64)>> = 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 entry = match caps.get(g) { - Some(m) => (Some(m.as_str().to_string()), (m.start() + offset) as i64), - None if unmatched_as_null => (None, -1), - None => (Some(String::new()), -1), + Some(m) => (Some(m.as_str().to_string()), m.start() as i64), + None => (None, -1), }; column.push(entry); } -- cgit v1.3.1-4-g156e