From 704ba2d87733657dea852fa697fc6d23a961a71b Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 17 Aug 2026 04:18:59 +0900 Subject: refactor(preg): replace Preg::split*() with shim preg_split*() preg_split2()'s limit was always -1 and its flags were always either 0 or PREG_SPLIT_DELIM_CAPTURE alone, so both arguments are gone: the shim now exposes preg_split() and preg_split_delim_capture() over a shared preg_split_impl(). That leaves Preg::split()/split4() as bare pass-throughs, so callers use the shim functions directly and the wrappers are dropped along with the now-unreferenced PREG_SPLIT_* constants. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe-pcre/src/preg.rs | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'crates/shirabe-pcre/src') diff --git a/crates/shirabe-pcre/src/preg.rs b/crates/shirabe-pcre/src/preg.rs index 55388a9f..f45b86df 100644 --- a/crates/shirabe-pcre/src/preg.rs +++ b/crates/shirabe-pcre/src/preg.rs @@ -14,9 +14,9 @@ use indexmap::IndexMap; pub use shirabe_php_shim::CaptureKey; use shirabe_php_shim::{ - PREG_OFFSET_CAPTURE, PREG_SET_ORDER, PREG_SPLIT_OFFSET_CAPTURE, PREG_UNMATCHED_AS_NULL, - PregPattern, preg_grep, preg_match_all_offset_capture, preg_match_all2, preg_match2, - preg_replace_callback, preg_replace2, preg_split2, + PREG_OFFSET_CAPTURE, PREG_SET_ORDER, PREG_UNMATCHED_AS_NULL, PregPattern, preg_grep, + preg_match_all_offset_capture, preg_match_all2, preg_match2, preg_replace_callback, + preg_replace2, }; #[derive(Debug)] @@ -120,19 +120,6 @@ impl Preg { preg_replace_callback(pattern, adapter, subject).expect("$replacement cannot fail") } - pub fn split(pattern: impl PregPattern, subject: &str) -> Vec { - Self::split4(pattern, subject, -1, 0) - } - - pub fn split4(pattern: impl PregPattern, subject: &str, limit: i64, flags: i64) -> Vec { - assert!( - flags & PREG_SPLIT_OFFSET_CAPTURE == 0, - "PREG_SPLIT_OFFSET_CAPTURE is not supported as it changes the type of $matches, use splitWithOffsets() instead" - ); - - preg_split2(pattern, subject, limit, flags) - } - pub fn grep>( pattern: impl PregPattern, array: impl IntoIterator, -- cgit v1.3.1-4-g156e