|
8 | 8 | // option. This file may not be copied, modified, or distributed
|
9 | 9 | // except according to those terms.
|
10 | 10 |
|
11 |
| -use std::cmp; |
12 | 11 | use std::mem;
|
13 | 12 |
|
14 | 13 | use aho_corasick::{Automaton, AcAutomaton, FullAcAutomaton};
|
@@ -681,7 +680,13 @@ impl BoyerMooreSearch {
|
681 | 680 | /// to beat the asm deep magic that is memchr. Unfortunately,
|
682 | 681 | /// I had trouble proving a useful turnover point. Hopefully,
|
683 | 682 | /// we can find one in the future.
|
684 |
| - fn should_use(pattern: &[u8]) -> bool { |
| 683 | + fn should_use(_pattern: &[u8]) -> bool { |
| 684 | + // TBM is disabled until the bm_backstop_boundary unit test can pass |
| 685 | + // and we're more confident that the implementation is correct. |
| 686 | + // |
| 687 | + // See: https://github.com/rust-lang/regex/issues/446 |
| 688 | + false |
| 689 | + /* |
685 | 690 | // The minimum pattern length required to use TBM.
|
686 | 691 | const MIN_LEN: usize = 9;
|
687 | 692 | // The minimum frequency rank (lower is rarer) that every byte in the
|
@@ -709,6 +714,7 @@ impl BoyerMooreSearch {
|
709 | 714 | pattern.len() > MIN_LEN
|
710 | 715 | // all the bytes must be more common than the cutoff.
|
711 | 716 | && pattern.iter().all(|c| freq_rank(*c) >= cutoff)
|
| 717 | + */ |
712 | 718 | }
|
713 | 719 |
|
714 | 720 | /// Check to see if there is a match at the given position
|
@@ -939,6 +945,22 @@ mod tests {
|
939 | 945 | assert_eq!(needle_start, searcher.find(haystack.as_slice()).unwrap());
|
940 | 946 | }
|
941 | 947 |
|
| 948 | + #[test] |
| 949 | + #[should_panic] |
| 950 | + fn bm_backstop_boundary() { |
| 951 | + let haystack = b"\ |
| 952 | +// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
| 953 | +e_data.clone_created(entity_id, entity_to_add.entity_id); |
| 954 | +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
| 955 | +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
| 956 | +".to_vec(); |
| 957 | + let needle = b"clone_created".to_vec(); |
| 958 | + |
| 959 | + let searcher = BoyerMooreSearch::new(needle); |
| 960 | + let result = searcher.find(&haystack); |
| 961 | + assert_eq!(Some(43), result); |
| 962 | + } |
| 963 | + |
942 | 964 | #[test]
|
943 | 965 | fn bm_win_gnu_indexing_bug() {
|
944 | 966 | let haystack_raw = vec![
|
|
0 commit comments