Commit 9a2165c7 authored by sandholm@chromium.org's avatar sandholm@chromium.org

An attempt to resolve the win32 build error introduced in r8506

Review URL: http://codereview.chromium.org/7278018

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8508 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 33177880
...@@ -5745,6 +5745,27 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) { ...@@ -5745,6 +5745,27 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) {
} }
void FindAsciiStringIndices(Vector<const char> subject,
char pattern,
ZoneList<int>* indices,
unsigned int limit) {
ASSERT(limit > 0);
// Collect indices of pattern in subject using memchr.
// Stop after finding at most limit values.
const char* subject_start = reinterpret_cast<const char*>(subject.start());
const char* subject_end = subject_start + subject.length();
const char* pos = subject_start;
while (limit > 0) {
pos = reinterpret_cast<const char*>(
memchr(pos, pattern, subject_end - pos));
if (pos == NULL) return;
indices->Add(pos - subject_start);
pos++;
limit--;
}
}
template <typename SubjectChar, typename PatternChar> template <typename SubjectChar, typename PatternChar>
void FindStringIndices(Isolate* isolate, void FindStringIndices(Isolate* isolate,
Vector<const SubjectChar> subject, Vector<const SubjectChar> subject,
...@@ -5752,38 +5773,21 @@ void FindStringIndices(Isolate* isolate, ...@@ -5752,38 +5773,21 @@ void FindStringIndices(Isolate* isolate,
ZoneList<int>* indices, ZoneList<int>* indices,
unsigned int limit) { unsigned int limit) {
ASSERT(limit > 0); ASSERT(limit > 0);
// Collect indices of pattern in subject, and the end-of-string index. // Collect indices of pattern in subject.
// Stop after finding at most limit values. // Stop after finding at most limit values.
int pattern_length = pattern.length(); int pattern_length = pattern.length();
int index = 0; int index = 0;
if (sizeof(SubjectChar) == kCharSize && StringSearch<PatternChar, SubjectChar> search(isolate, pattern);
sizeof(PatternChar) == kCharSize && while (limit > 0) {
pattern_length == 1) { index = search.Search(subject, index);
// ASCII subject with one char ASCII pattern allows direct use of memchr. if (index < 0) return;
char pattern_first_char = pattern[0]; indices->Add(index);
const char* subject_start = reinterpret_cast<const char*>(subject.start()); index += pattern_length;
const char* subject_end = subject_start + subject.length(); limit--;
const char* pos = subject_start;
while (limit > 0) {
pos = reinterpret_cast<const char*>(
memchr(pos, pattern_first_char, subject_end - pos));
if (pos == NULL) return;
indices->Add(pos - subject_start);
pos++;
limit--;
}
} else {
StringSearch<PatternChar, SubjectChar> search(isolate, pattern);
while (limit > 0) {
index = search.Search(subject, index);
if (index < 0) return;
indices->Add(index);
index += pattern_length;
limit--;
}
} }
} }
RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) { RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) {
ASSERT(args.length() == 3); ASSERT(args.length() == 3);
HandleScope handle_scope(isolate); HandleScope handle_scope(isolate);
...@@ -5816,11 +5820,19 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) { ...@@ -5816,11 +5820,19 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) {
if (subject->IsAsciiRepresentation()) { if (subject->IsAsciiRepresentation()) {
Vector<const char> subject_vector = subject->ToAsciiVector(); Vector<const char> subject_vector = subject->ToAsciiVector();
if (pattern->IsAsciiRepresentation()) { if (pattern->IsAsciiRepresentation()) {
FindStringIndices(isolate, Vector<const char> pattern_vector = pattern->ToAsciiVector();
subject_vector, if (pattern_vector.length() == 1) {
pattern->ToAsciiVector(), FindAsciiStringIndices(subject_vector,
&indices, pattern_vector[0],
limit); &indices,
limit);
} else {
FindStringIndices(isolate,
subject_vector,
pattern_vector,
&indices,
limit);
}
} else { } else {
FindStringIndices(isolate, FindStringIndices(isolate,
subject_vector, subject_vector,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment