@@ -80,12 +80,12 @@ class StringSearchBase {
8080 static const int kBMMinPatternLength = 8 ;
8181
8282 // Store for the BoyerMoore(Horspool) bad char shift table.
83- static int kBadCharShiftTable [kUC16AlphabetSize ];
83+ int bad_char_shift_table_ [kUC16AlphabetSize ];
8484 // Store for the BoyerMoore good suffix shift table.
85- static int kGoodSuffixShiftTable [kBMMaxShift + 1 ];
85+ int good_suffix_shift_table_ [kBMMaxShift + 1 ];
8686 // Table used temporarily while building the BoyerMoore good suffix
8787 // shift table.
88- static int kSuffixTable [kBMMaxShift + 1 ];
88+ int suffix_table_ [kBMMaxShift + 1 ];
8989};
9090
9191template <typename Char>
@@ -152,26 +152,6 @@ class StringSearch : private StringSearchBase {
152152 return bad_char_occurrence[equiv_class];
153153 }
154154
155- // Store for the BoyerMoore(Horspool) bad char shift table.
156- // Return a table covering the last kBMMaxShift+1 positions of
157- // pattern.
158- int * bad_char_table () { return kBadCharShiftTable ; }
159-
160- // Store for the BoyerMoore good suffix shift table.
161- int * good_suffix_shift_table () {
162- // Return biased pointer that maps the range [start_..pattern_.length()
163- // to the kGoodSuffixShiftTable array.
164- return kGoodSuffixShiftTable - start_;
165- }
166-
167- // Table used temporarily while building the BoyerMoore good suffix
168- // shift table.
169- int * suffix_table () {
170- // Return biased pointer that maps the range [start_..pattern_.length()
171- // to the kSuffixTable array.
172- return kSuffixTable - start_;
173- }
174-
175155 // The pattern to search for.
176156 Vector pattern_;
177157 // Pointer to implementation of the search.
@@ -345,8 +325,8 @@ size_t StringSearch<Char>::BoyerMooreSearch(
345325 // Only preprocess at most kBMMaxShift last characters of pattern.
346326 size_t start = start_;
347327
348- int * bad_char_occurrence = bad_char_table () ;
349- int * good_suffix_shift = good_suffix_shift_table () ;
328+ int * bad_char_occurrence = bad_char_shift_table_ ;
329+ int * good_suffix_shift = good_suffix_shift_table_ - start_ ;
350330
351331 Char last_char = pattern_[pattern_length - 1 ];
352332 size_t index = start_index;
@@ -397,8 +377,8 @@ void StringSearch<Char>::PopulateBoyerMooreTable() {
397377
398378 // Biased tables so that we can use pattern indices as table indices,
399379 // even if we only cover the part of the pattern from offset start.
400- int * shift_table = good_suffix_shift_table () ;
401- int * suffix_table = this -> suffix_table () ;
380+ int * shift_table = good_suffix_shift_table_ - start_ ;
381+ int * suffix_table = suffix_table_ - start_ ;
402382
403383 // Initialize table.
404384 for (size_t i = start; i < pattern_length; i++) {
@@ -462,7 +442,7 @@ size_t StringSearch<Char>::BoyerMooreHorspoolSearch(
462442 size_t start_index) {
463443 const size_t subject_length = subject.length ();
464444 const size_t pattern_length = pattern_.length ();
465- int * char_occurrences = bad_char_table () ;
445+ int * char_occurrences = bad_char_shift_table_ ;
466446 int64_t badness = -pattern_length;
467447
468448 // How bad we are doing without a good-suffix table.
@@ -511,7 +491,7 @@ template <typename Char>
511491void StringSearch<Char>::PopulateBoyerMooreHorspoolTable() {
512492 const size_t pattern_length = pattern_.length ();
513493
514- int * bad_char_occurrence = bad_char_table () ;
494+ int * bad_char_occurrence = bad_char_shift_table_ ;
515495
516496 // Only preprocess at most kBMMaxShift last characters of pattern.
517497 const size_t start = start_;
0 commit comments