reduces constant overhead
(
prog: &'a Program,
cache: &ProgramCache,
matches: &mut [bool],
text: &[u8],
at: usize,
)
| 524 | |
| 525 | #[inline(always)] // reduces constant overhead |
| 526 | pub fn forward_many( |
| 527 | prog: &'a Program, |
| 528 | cache: &ProgramCache, |
| 529 | matches: &mut [bool], |
| 530 | text: &[u8], |
| 531 | at: usize, |
| 532 | ) -> Result<usize> { |
| 533 | debug_assert!(matches.len() == prog.matches.len()); |
| 534 | let mut cache = cache.borrow_mut(); |
| 535 | let cache = &mut cache.dfa; |
| 536 | let mut dfa = Fsm { |
| 537 | prog: prog, |
| 538 | start: 0, // filled in below |
| 539 | at: at, |
| 540 | quit_after_match: false, |
| 541 | last_match_si: STATE_UNKNOWN, |
| 542 | last_cache_flush: at, |
| 543 | cache: &mut cache.inner, |
| 544 | }; |
| 545 | let (empty_flags, state_flags) = dfa.start_flags(text, at); |
| 546 | dfa.start = match dfa.start_state( |
| 547 | &mut cache.qcur, |
| 548 | empty_flags, |
| 549 | state_flags, |
| 550 | ) { |
| 551 | None => return Result::Quit, |
| 552 | Some(STATE_DEAD) => return Result::NoMatch(at), |
| 553 | Some(si) => si, |
| 554 | }; |
| 555 | debug_assert!(dfa.start != STATE_UNKNOWN); |
| 556 | let result = dfa.exec_at(&mut cache.qcur, &mut cache.qnext, text); |
| 557 | if result.is_match() { |
| 558 | if matches.len() == 1 { |
| 559 | matches[0] = true; |
| 560 | } else { |
| 561 | debug_assert!(dfa.last_match_si != STATE_UNKNOWN); |
| 562 | debug_assert!(dfa.last_match_si != STATE_DEAD); |
| 563 | for ip in dfa.state(dfa.last_match_si).inst_ptrs() { |
| 564 | if let Inst::Match(slot) = dfa.prog[ip] { |
| 565 | matches[slot] = true; |
| 566 | } |
| 567 | } |
| 568 | } |
| 569 | } |
| 570 | result |
| 571 | } |
| 572 | |
| 573 | /// Executes the DFA on a forward NFA. |
| 574 | /// |
nothing calls this directly
no test coverage detected