| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // Bad-char shift table stored in the state. It's length is the alphabet size. | 59 // Bad-char shift table stored in the state. It's length is the alphabet size. |
| 60 // For patterns below this length, the skip length of Boyer-Moore is too short | 60 // For patterns below this length, the skip length of Boyer-Moore is too short |
| 61 // to compensate for the algorithmic overhead compared to simple brute force. | 61 // to compensate for the algorithmic overhead compared to simple brute force. |
| 62 static const int kBMMinPatternLength = 7; | 62 static const int kBMMinPatternLength = 7; |
| 63 | 63 |
| 64 static inline bool IsAsciiString(Vector<const char>) { | 64 static inline bool IsAsciiString(Vector<const char>) { |
| 65 return true; | 65 return true; |
| 66 } | 66 } |
| 67 | 67 |
| 68 static inline bool IsAsciiString(Vector<const uc16> string) { | 68 static inline bool IsAsciiString(Vector<const uc16> string) { |
| 69 for (int i = 0, n = string.length(); i < n; i++) { | 69 return String::IsAscii(string.start(), string.length()); |
| 70 if (static_cast<unsigned>(string[i]) > String::kMaxAsciiCharCodeU) { | |
| 71 return false; | |
| 72 } | |
| 73 } | |
| 74 return true; | |
| 75 } | 70 } |
| 76 | 71 |
| 77 friend class Isolate; | 72 friend class Isolate; |
| 78 }; | 73 }; |
| 79 | 74 |
| 80 | 75 |
| 81 template <typename PatternChar, typename SubjectChar> | 76 template <typename PatternChar, typename SubjectChar> |
| 82 class StringSearch : private StringSearchBase { | 77 class StringSearch : private StringSearchBase { |
| 83 public: | 78 public: |
| 84 StringSearch(Isolate* isolate, Vector<const PatternChar> pattern) | 79 StringSearch(Isolate* isolate, Vector<const PatternChar> pattern) |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 Vector<const SubjectChar> subject, | 559 Vector<const SubjectChar> subject, |
| 565 Vector<const PatternChar> pattern, | 560 Vector<const PatternChar> pattern, |
| 566 int start_index) { | 561 int start_index) { |
| 567 StringSearch<PatternChar, SubjectChar> search(isolate, pattern); | 562 StringSearch<PatternChar, SubjectChar> search(isolate, pattern); |
| 568 return search.Search(subject, start_index); | 563 return search.Search(subject, start_index); |
| 569 } | 564 } |
| 570 | 565 |
| 571 }} // namespace v8::internal | 566 }} // namespace v8::internal |
| 572 | 567 |
| 573 #endif // V8_STRING_SEARCH_H_ | 568 #endif // V8_STRING_SEARCH_H_ |
| OLD | NEW |