Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Side by Side Diff: src/string-search.h

Issue 3535004: Merge svn r5572 from bleeding_edge. (Closed)
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/version.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 void PopulateBoyerMooreHorspoolTable(); 163 void PopulateBoyerMooreHorspoolTable();
164 164
165 void PopulateBoyerMooreTable(); 165 void PopulateBoyerMooreTable();
166 166
167 static inline int CharOccurrence(int* bad_char_occurrence, 167 static inline int CharOccurrence(int* bad_char_occurrence,
168 SubjectChar char_code) { 168 SubjectChar char_code) {
169 if (sizeof(SubjectChar) == 1) { 169 if (sizeof(SubjectChar) == 1) {
170 return bad_char_occurrence[static_cast<int>(char_code)]; 170 return bad_char_occurrence[static_cast<int>(char_code)];
171 } 171 }
172 if (sizeof(PatternChar) == 1) { 172 if (sizeof(PatternChar) == 1) {
173 if (static_cast<unsigned char>(char_code) > String::kMaxAsciiCharCode) { 173 if (static_cast<unsigned int>(char_code) > String::kMaxAsciiCharCodeU) {
174 return -1; 174 return -1;
175 } 175 }
176 return bad_char_occurrence[static_cast<int>(char_code)]; 176 return bad_char_occurrence[static_cast<unsigned int>(char_code)];
177 } 177 }
178 // Reduce to equivalence class. 178 // Both pattern and subject are UC16. Reduce character to equivalence class.
179 int equiv_class = char_code % kUC16AlphabetSize; 179 int equiv_class = char_code % kUC16AlphabetSize;
180 return bad_char_occurrence[equiv_class]; 180 return bad_char_occurrence[equiv_class];
181 } 181 }
182 182
183 // Return a table covering the last kBMMaxShift+1 positions of 183 // Return a table covering the last kBMMaxShift+1 positions of
184 // pattern. 184 // pattern.
185 int* bad_char_table() { 185 int* bad_char_table() {
186 return kBadCharShiftTable; 186 return kBadCharShiftTable;
187 } 187 }
188 188
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 static int SearchString(Vector<const SubjectChar> subject, 563 static int SearchString(Vector<const SubjectChar> subject,
564 Vector<const PatternChar> pattern, 564 Vector<const PatternChar> pattern,
565 int start_index) { 565 int start_index) {
566 StringSearch<PatternChar, SubjectChar> search(pattern); 566 StringSearch<PatternChar, SubjectChar> search(pattern);
567 return search.Search(subject, start_index); 567 return search.Search(subject, start_index);
568 } 568 }
569 569
570 }} // namespace v8::internal 570 }} // namespace v8::internal
571 571
572 #endif // V8_STRING_SEARCH_H_ 572 #endif // V8_STRING_SEARCH_H_
OLDNEW
« no previous file with comments | « no previous file | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698