diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-17 03:58:46 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-17 03:58:46 +0900 |
| commit | dc0cc70f6916810f326d6019a4bec90ca2915904 (patch) | |
| tree | 7e687ca2fe901d5ac97404222d426fdbc0748a1c /crates/shirabe-pcre/src | |
| parent | 879affc50810e1ebb20687265a9a4e9801e21af2 (diff) | |
| download | php-shirabe-dc0cc70f6916810f326d6019a4bec90ca2915904.tar.gz php-shirabe-dc0cc70f6916810f326d6019a4bec90ca2915904.tar.zst php-shirabe-dc0cc70f6916810f326d6019a4bec90ca2915904.zip | |
refactor(preg): drop Option wrapper from matches arg of match_all*()
Every caller of Preg::match_all3()/is_match_all3() passed Some(&mut _),
so the argument is now a plain &mut. Preg::match_all() keeps the
no-captures form with a local throwaway map, and the arity suffixes are
renumbered accordingly (match_all2(), is_match_all()).
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.rs | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/crates/shirabe-pcre/src/preg.rs b/crates/shirabe-pcre/src/preg.rs index 10ed1d5b..55388a9f 100644 --- a/crates/shirabe-pcre/src/preg.rs +++ b/crates/shirabe-pcre/src/preg.rs @@ -57,22 +57,16 @@ impl Preg { } pub fn match_all(pattern: impl PregPattern, subject: &str) -> usize { - Self::match_all3(pattern, subject, None) + let mut dummy = IndexMap::new(); + preg_match_all2(pattern, subject, &mut dummy) } - pub fn match_all3( + pub fn match_all2( pattern: impl PregPattern, subject: &str, - matches: Option<&mut IndexMap<CaptureKey, Vec<Option<String>>>>, + matches: &mut IndexMap<CaptureKey, Vec<Option<String>>>, ) -> usize { - let mut internal: IndexMap<CaptureKey, Vec<Option<String>>> = IndexMap::new(); - let result = preg_match_all2(pattern, subject, &mut internal); - - if let Some(out) = matches { - *out = internal; - } - - result + preg_match_all2(pattern, subject, matches) } fn match_all_with_offsets5( @@ -220,12 +214,12 @@ impl Preg { Some(captures) } - pub fn is_match_all3( + pub fn is_match_all( pattern: impl PregPattern, subject: &str, - matches: Option<&mut IndexMap<CaptureKey, Vec<Option<String>>>>, + matches: &mut IndexMap<CaptureKey, Vec<Option<String>>>, ) -> bool { - Self::match_all3(pattern, subject, matches) > 0 + Self::match_all2(pattern, subject, matches) > 0 } pub fn is_match_all_with_offsets3( |
