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

Unified Diff: src/string-search.h

Issue 6685088: Merge isolates to bleeding_edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/spaces-inl.h ('k') | src/string-search.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/string-search.h
===================================================================
--- src/string-search.h (revision 7267)
+++ src/string-search.h (working copy)
@@ -44,7 +44,7 @@
// limit, we can fix the size of tables. For a needle longer than this limit,
// search will not be optimal, since we only build tables for a suffix
// of the string, but it is a safe approximation.
- static const int kBMMaxShift = 250;
+ static const int kBMMaxShift = Isolate::kBMMaxShift;
// Reduce alphabet to this size.
// One of the tables used by Boyer-Moore and Boyer-Moore-Horspool has size
@@ -54,7 +54,7 @@
// For needles using only characters in the same Unicode 256-code point page,
// there is no search speed degradation.
static const int kAsciiAlphabetSize = 128;
- static const int kUC16AlphabetSize = 256;
+ static const int kUC16AlphabetSize = Isolate::kUC16AlphabetSize;
// Bad-char shift table stored in the state. It's length is the alphabet size.
// For patterns below this length, the skip length of Boyer-Moore is too short
@@ -69,25 +69,16 @@
return String::IsAscii(string.start(), string.length());
}
- // The following tables are shared by all searches.
- // TODO(lrn): Introduce a way for a pattern to keep its tables
- // between searches (e.g., for an Atom RegExp).
-
- // Store for the BoyerMoore(Horspool) bad char shift table.
- static int kBadCharShiftTable[kUC16AlphabetSize];
- // Store for the BoyerMoore good suffix shift table.
- static int kGoodSuffixShiftTable[kBMMaxShift + 1];
- // Table used temporarily while building the BoyerMoore good suffix
- // shift table.
- static int kSuffixTable[kBMMaxShift + 1];
+ friend class Isolate;
};
template <typename PatternChar, typename SubjectChar>
class StringSearch : private StringSearchBase {
public:
- explicit StringSearch(Vector<const PatternChar> pattern)
- : pattern_(pattern),
+ StringSearch(Isolate* isolate, Vector<const PatternChar> pattern)
+ : isolate_(isolate),
+ pattern_(pattern),
start_(Max(0, pattern.length() - kBMMaxShift)) {
if (sizeof(PatternChar) > sizeof(SubjectChar)) {
if (!IsAsciiString(pattern_)) {
@@ -175,24 +166,33 @@
return bad_char_occurrence[equiv_class];
}
+ // The following tables are shared by all searches.
+ // TODO(lrn): Introduce a way for a pattern to keep its tables
+ // between searches (e.g., for an Atom RegExp).
+
+ // Store for the BoyerMoore(Horspool) bad char shift table.
// Return a table covering the last kBMMaxShift+1 positions of
// pattern.
int* bad_char_table() {
- return kBadCharShiftTable;
+ return isolate_->bad_char_shift_table();
}
+ // Store for the BoyerMoore good suffix shift table.
int* good_suffix_shift_table() {
// Return biased pointer that maps the range [start_..pattern_.length()
// to the kGoodSuffixShiftTable array.
- return kGoodSuffixShiftTable - start_;
+ return isolate_->good_suffix_shift_table() - start_;
}
+ // Table used temporarily while building the BoyerMoore good suffix
+ // shift table.
int* suffix_table() {
// Return biased pointer that maps the range [start_..pattern_.length()
// to the kSuffixTable array.
- return kSuffixTable - start_;
+ return isolate_->suffix_table() - start_;
}
+ Isolate* isolate_;
// The pattern to search for.
Vector<const PatternChar> pattern_;
// Pointer to implementation of the search.
@@ -555,10 +555,11 @@
// object should be constructed once and the Search function then called
// for each search.
template <typename SubjectChar, typename PatternChar>
-static int SearchString(Vector<const SubjectChar> subject,
+static int SearchString(Isolate* isolate,
+ Vector<const SubjectChar> subject,
Vector<const PatternChar> pattern,
int start_index) {
- StringSearch<PatternChar, SubjectChar> search(pattern);
+ StringSearch<PatternChar, SubjectChar> search(isolate, pattern);
return search.Search(subject, start_index);
}
« no previous file with comments | « src/spaces-inl.h ('k') | src/string-search.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698