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

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

Issue 5963003: Clean up is-ASCII checks. (Closed)
Patch Set: Created 9 years, 12 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
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // The following tables are shared by all searches. 72 // The following tables are shared by all searches.
78 // TODO(lrn): Introduce a way for a pattern to keep its tables 73 // TODO(lrn): Introduce a way for a pattern to keep its tables
79 // between searches (e.g., for an Atom RegExp). 74 // between searches (e.g., for an Atom RegExp).
80 75
81 // Store for the BoyerMoore(Horspool) bad char shift table. 76 // Store for the BoyerMoore(Horspool) bad char shift table.
82 static int kBadCharShiftTable[kUC16AlphabetSize]; 77 static int kBadCharShiftTable[kUC16AlphabetSize];
83 // Store for the BoyerMoore good suffix shift table. 78 // Store for the BoyerMoore good suffix shift table.
84 static int kGoodSuffixShiftTable[kBMMaxShift + 1]; 79 static int kGoodSuffixShiftTable[kBMMaxShift + 1];
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 static int SearchString(Vector<const SubjectChar> subject, 558 static int SearchString(Vector<const SubjectChar> subject,
564 Vector<const PatternChar> pattern, 559 Vector<const PatternChar> pattern,
565 int start_index) { 560 int start_index) {
566 StringSearch<PatternChar, SubjectChar> search(pattern); 561 StringSearch<PatternChar, SubjectChar> search(pattern);
567 return search.Search(subject, start_index); 562 return search.Search(subject, start_index);
568 } 563 }
569 564
570 }} // namespace v8::internal 565 }} // namespace v8::internal
571 566
572 #endif // V8_STRING_SEARCH_H_ 567 #endif // V8_STRING_SEARCH_H_
OLDNEW
« src/heap.cc ('K') | « src/objects.h ('k') | src/x64/regexp-macro-assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698