From 6aeda8b237fcbf7a56ca0e8c0fff415477d31d22 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 18 Aug 2026 01:57:02 +0900 Subject: refactor(preg): make preg_match_all yield matches per occurrence PHP's PREG_PATTERN_ORDER is column-oriented, but 7 of the 10 call sites read it row-wise, rebuilding each occurrence by indexing every column at the same offset. Return an iterator of PregMatches instead, which is also what the set-order and offset-capture variants were carrying, so the three functions collapse into one and PregMatchesAll, PregMatchesAllWithOffsets, CaptureKey and preg_match_map! all go away. The offset-capture call sites are served by the new PregMatches get_offset/name_offset accessors. The search stays eager: regex::Captures borrows only the subject, so the matches outlive the pattern resolved for the call, and PHP's preg_match_all is eager too. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe-symfony-console/src/completion/completion_input.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'crates/shirabe-symfony-console/src/completion/completion_input.rs') diff --git a/crates/shirabe-symfony-console/src/completion/completion_input.rs b/crates/shirabe-symfony-console/src/completion/completion_input.rs index 41c15ec5..e7f1e0a2 100644 --- a/crates/shirabe-symfony-console/src/completion/completion_input.rs +++ b/crates/shirabe-symfony-console/src/completion/completion_input.rs @@ -3,7 +3,7 @@ use crate::input::ArgvInput; use crate::input::InputDefinition; use crate::input::InputOption; -use shirabe_php_shim::{CaptureKey, PhpMixed, php_regex, preg_match_all}; +use shirabe_php_shim::{PhpMixed, php_regex, preg_match_all}; /// An input specialized for shell completion. /// @@ -36,13 +36,11 @@ impl CompletionInput { Self::from_tokens( tokens - .get(&CaptureKey::ByIndex(0)) - .expect("group 0 is always present") - .iter() .map(|token| { token - .clone() + .get(0) .expect("group 0 participates whenever the pattern matches") + .to_string() }) .collect(), current_index, -- cgit v1.3.1-4-g156e