Skip to content

Commit 052176d

Browse files
committed
regex/literals: re-enable Tuned Boyer-Moore
We've added tests and carefully scrutinized it. Let's try this again.
1 parent d756dba commit 052176d

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/literals.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use std::cmp;
1112
use std::mem;
1213

1314
use aho_corasick::{Automaton, AcAutomaton, FullAcAutomaton};
@@ -682,13 +683,7 @@ impl BoyerMooreSearch {
682683
/// to beat the asm deep magic that is memchr. Unfortunately,
683684
/// I had trouble proving a useful turnover point. Hopefully,
684685
/// we can find one in the future.
685-
fn should_use(_pattern: &[u8]) -> bool {
686-
// TBM is disabled until the bm_backstop_boundary unit test can pass
687-
// and we're more confident that the implementation is correct.
688-
//
689-
// See: https://github.com/rust-lang/regex/issues/446
690-
false
691-
/*
686+
fn should_use(pattern: &[u8]) -> bool {
692687
// The minimum pattern length required to use TBM.
693688
const MIN_LEN: usize = 9;
694689
// The minimum frequency rank (lower is rarer) that every byte in the
@@ -716,7 +711,6 @@ impl BoyerMooreSearch {
716711
pattern.len() > MIN_LEN
717712
// all the bytes must be more common than the cutoff.
718713
&& pattern.iter().all(|c| freq_rank(*c) >= cutoff)
719-
*/
720714
}
721715

722716
/// Check to see if there is a match at the given position

0 commit comments

Comments
 (0)