Skip to content

Commit cf0928c

Browse files
mscdexevanlucas
authored andcommitted
src: clean up string_search
This commit removes some unnecessary signed checks on unsigned variables and removes a few unused private functions. PR-URL: #7174 Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent d71ede8 commit cf0928c

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

src/string_search.h

+3-15
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Vector {
4444

4545
// Access individual vector elements - checks bounds in debug mode.
4646
T& operator[](size_t index) const {
47-
ASSERT(0 <= index && index < length_);
47+
ASSERT(index < length_);
4848
return start_[is_forward_ ? index : (length_ - index - 1)];
4949
}
5050

@@ -139,12 +139,6 @@ class StringSearch : private StringSearchBase {
139139
Vector<const Char>,
140140
size_t);
141141

142-
static size_t FailSearch(StringSearch<Char>*,
143-
Vector<const Char> subject,
144-
size_t) {
145-
return subject.length();
146-
}
147-
148142
static size_t SingleCharSearch(StringSearch<Char>* search,
149143
Vector<const Char> subject,
150144
size_t start_index);
@@ -170,12 +164,6 @@ class StringSearch : private StringSearchBase {
170164

171165
void PopulateBoyerMooreTable();
172166

173-
static inline bool exceedsOneByte(uint8_t c) { return false; }
174-
175-
static inline bool exceedsOneByte(uint16_t c) {
176-
return c > kMaxOneByteCharCodeU;
177-
}
178-
179167
static inline int CharOccurrence(int* bad_char_occurrence,
180168
Char char_code) {
181169
if (sizeof(Char) == 1) {
@@ -401,7 +389,7 @@ size_t StringSearch<Char>::BoyerMooreSearch(
401389
return subject.length();
402390
}
403391
}
404-
while (j >= 0 && pattern[j] == (c = subject[index + j])) {
392+
while (pattern[j] == (c = subject[index + j])) {
405393
if (j == 0) {
406394
return index;
407395
}
@@ -529,7 +517,7 @@ size_t StringSearch<Char>::BoyerMooreHorspoolSearch(
529517
}
530518
}
531519
j--;
532-
while (j >= 0 && pattern[j] == (subject[index + j])) {
520+
while (pattern[j] == (subject[index + j])) {
533521
if (j == 0) {
534522
return index;
535523
}

0 commit comments

Comments
 (0)