]> git.proxmox.com Git - cargo.git/blobdiff - vendor/regex/src/literal/teddy_ssse3/imp.rs
New upstream version 0.35.0
[cargo.git] / vendor / regex / src / literal / teddy_ssse3 / imp.rs
index 85422b64095a7c62a9fa1e2c01d344967f9b6b39..c3dc31e04b2d0b912bf23f6f9605dcaf8b330f32 100644 (file)
@@ -320,7 +320,7 @@ References
 
 use std::cmp;
 
-use aho_corasick::{Automaton, AcAutomaton, FullAcAutomaton};
+use aho_corasick::{AhoCorasick, AhoCorasickBuilder};
 use syntax::hir::literal::Literals;
 
 use vector::ssse3::{SSSE3VectorBuilder, u8x16};
@@ -349,7 +349,7 @@ pub struct Teddy {
     pats: Vec<Vec<u8>>,
     /// An Aho-Corasick automaton of the patterns. We use this when we need to
     /// search pieces smaller than the Teddy block size.
-    ac: FullAcAutomaton<Vec<u8>>,
+    ac: AhoCorasick,
     /// A set of 8 buckets. Each bucket corresponds to a single member of a
     /// bitset. A bucket contains zero or more substrings. This is useful
     /// when the number of substrings exceeds 8, since our bitsets cannot have
@@ -399,10 +399,14 @@ impl Teddy {
             buckets[bucket].push(pati);
             masks.add(bucket as u8, pat);
         }
+        let ac = AhoCorasickBuilder::new()
+            .dfa(true)
+            .prefilter(false)
+            .build(&pats);
         Some(Teddy {
             vb: vb,
             pats: pats.to_vec(),
-            ac: AcAutomaton::new(pats.to_vec()).into_full(),
+            ac: ac,
             buckets: buckets,
             masks: masks,
         })
@@ -651,11 +655,11 @@ impl Teddy {
     /// block based approach.
     #[inline(never)]
     fn slow(&self, haystack: &[u8], pos: usize) -> Option<Match> {
-        self.ac.find(&haystack[pos..]).next().map(|m| {
+        self.ac.find(&haystack[pos..]).map(|m| {
             Match {
-                pat: m.pati,
-                start: pos + m.start,
-                end: pos + m.end,
+                pat: m.pattern(),
+                start: pos + m.start(),
+                end: pos + m.end(),
             }
         })
     }