Index: src/string-search.h |
diff --git a/src/string-search.h b/src/string-search.h |
index ae5f60809d0cd904599448704aba88071306f1ba..882f747b5a56c275e3c2fdffe1feb06abad8ce8d 100644 |
--- a/src/string-search.h |
+++ b/src/string-search.h |
@@ -53,7 +53,11 @@ class StringSearchBase { |
// a potentially less efficient searching, but is a safe approximation. |
// For needles using only characters in the same Unicode 256-code point page, |
// there is no search speed degradation. |
+#ifndef ENABLE_LATIN_1 |
static const int kAsciiAlphabetSize = 128; |
+#else |
+ static const int kAsciiAlphabetSize = 256; |
+#endif |
static const int kUC16AlphabetSize = Isolate::kUC16AlphabetSize; |
// Bad-char shift table stored in the state. It's length is the alphabet size. |
@@ -61,7 +65,7 @@ class StringSearchBase { |
// to compensate for the algorithmic overhead compared to simple brute force. |
static const int kBMMinPatternLength = 7; |
- static inline bool IsOneByteString(Vector<const char> string) { |
+ static inline bool IsOneByteString(Vector<const uint8_t> string) { |
return true; |
} |
@@ -150,13 +154,21 @@ class StringSearch : private StringSearchBase { |
void PopulateBoyerMooreTable(); |
+ static inline bool exceedsOneByte(uint8_t c) { |
+ return false; |
Yang
2013/01/09 15:39:30
Don't we still need to gate this with ENABLE_LATIN
|
+ } |
+ |
+ static inline bool exceedsOneByte(uint16_t c) { |
+ return c > String::kMaxOneByteCharCodeU; |
+ } |
+ |
static inline int CharOccurrence(int* bad_char_occurrence, |
SubjectChar char_code) { |
if (sizeof(SubjectChar) == 1) { |
return bad_char_occurrence[static_cast<int>(char_code)]; |
} |
if (sizeof(PatternChar) == 1) { |
- if (static_cast<unsigned int>(char_code) > String::kMaxOneByteCharCodeU) { |
+ if (exceedsOneByte(char_code)) { |
return -1; |
} |
return bad_char_occurrence[static_cast<unsigned int>(char_code)]; |
@@ -223,8 +235,7 @@ int StringSearch<PatternChar, SubjectChar>::SingleCharSearch( |
return static_cast<int>(pos - subject.start()); |
} else { |
if (sizeof(PatternChar) > sizeof(SubjectChar)) { |
- if (static_cast<uc16>(pattern_first_char) > |
- String::kMaxOneByteCharCodeU) { |
+ if (exceedsOneByte(pattern_first_char)) { |
return -1; |
} |
} |