MCPcopy Create free account
hub / github.com/davidblewett/rure-python / exec_dfa_reverse_suffix

Method exec_dfa_reverse_suffix

regex/src/exec.rs:779–815  ·  view source on GitHub ↗

reduces constant overhead

(
        &self,
        text: &[u8],
        original_start: usize,
    )

Source from the content-addressed store, hash-verified

777 /// matching engine should be used.
778 #[inline(always)] // reduces constant overhead
779 fn exec_dfa_reverse_suffix(
780 &self,
781 text: &[u8],
782 original_start: usize,
783 ) -> Option<dfa::Result<(usize, usize)>> {
784 use dfa::Result::*;
785
786 let lcs = self.ro.suffixes.lcs();
787 debug_assert!(lcs.len() >= 1);
788 let mut start = original_start;
789 let mut end = start;
790 let mut last_literal = start;
791 while end <= text.len() {
792 last_literal += match lcs.find(&text[last_literal..]) {
793 None => return Some(NoMatch(text.len())),
794 Some(i) => i,
795 };
796 end = last_literal + lcs.len();
797 match dfa::Fsm::reverse(
798 &self.ro.dfa_reverse,
799 self.cache,
800 false,
801 &text[start..end],
802 end - start,
803 ) {
804 Match(0) | NoMatch(0) => return None,
805 Match(i) => return Some(Match((start + i, end))),
806 NoMatch(i) => {
807 start += i;
808 last_literal += 1;
809 continue;
810 }
811 Quit => return Some(Quit),
812 };
813 }
814 Some(NoMatch(text.len()))
815 }
816
817 /// Finds the leftmost-first match (start and end) using only the DFA
818 /// by scanning for suffix literals.

Callers 2

Calls 4

lcsMethod · 0.80
MatchClass · 0.70
lenMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected