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

Unified Diff: src/api.cc

Issue 11688003: Revert r13275 and 13276 (Remove most uses of StringInputBuffer). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years 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 | « no previous file | src/codegen.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 929d380011b125d3b53eb9401c9f7b95d5450b6e..11d0a40de018576fb70c6870111879cf05174387 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -4043,9 +4043,10 @@ int String::WriteUtf8(char* buffer,
}
// Slow case.
- i::StringCharacterStream stream(*str, isolate->write_iterator());
+ i::StringInputBuffer& write_input_buffer = *isolate->write_input_buffer();
isolate->string_tracker()->RecordWrite(str);
+ write_input_buffer.Reset(0, *str);
int len = str->length();
// Encode the first K - 3 bytes directly into the buffer since we
// know there's room for them. If no capacity is given we copy all
@@ -4056,7 +4057,7 @@ int String::WriteUtf8(char* buffer,
int nchars = 0;
int previous = unibrow::Utf16::kNoPreviousCharacter;
for (i = 0; i < len && (capacity == -1 || pos < fast_end); i++) {
- i::uc32 c = stream.GetNext();
+ i::uc32 c = write_input_buffer.GetNext();
int written = unibrow::Utf8::Encode(buffer + pos, c, previous);
pos += written;
nchars++;
@@ -4068,7 +4069,7 @@ int String::WriteUtf8(char* buffer,
// buffer.
char intermediate[unibrow::Utf8::kMaxEncodedSize];
for (; i < len && pos < capacity; i++) {
- i::uc32 c = stream.GetNext();
+ i::uc32 c = write_input_buffer.GetNext();
if (unibrow::Utf16::IsTrailSurrogate(c) &&
unibrow::Utf16::IsLeadSurrogate(previous)) {
// We can't use the intermediate buffer here because the encoding
@@ -4124,7 +4125,7 @@ int String::WriteAscii(char* buffer,
}
if (str->IsOneByteRepresentation()) {
- // WriteToFlat is faster than using the StringCharacterStream.
+ // WriteToFlat is faster than using the StringInputBuffer.
if (length == -1) length = str->length() + 1;
int len = i::Min(length, str->length() - start);
i::String::WriteToFlat(*str, buffer, start, start + len);
@@ -4139,15 +4140,16 @@ int String::WriteAscii(char* buffer,
return len;
}
+ i::StringInputBuffer& write_input_buffer = *isolate->write_input_buffer();
int end = length;
if ((length == -1) || (length > str->length() - start)) {
end = str->length() - start;
}
if (end < 0) return 0;
- i::StringCharacterStream write_stream(*str, isolate->write_iterator(), start);
+ write_input_buffer.Reset(start, *str);
int i;
for (i = 0; i < end; i++) {
- char c = static_cast<char>(write_stream.GetNext());
+ char c = static_cast<char>(write_input_buffer.GetNext());
if (c == '\0' && !(options & PRESERVE_ASCII_NULL)) c = ' ';
buffer[i] = c;
}
@@ -4171,7 +4173,7 @@ int String::Write(uint16_t* buffer,
isolate->string_tracker()->RecordWrite(str);
if (options & HINT_MANY_WRITES_EXPECTED) {
// Flatten the string for efficiency. This applies whether we are
- // using StringCharacterStream or Get(i) to access the characters.
+ // using StringInputBuffer or Get(i) to access the characters.
FlattenString(str);
}
int end = start + length;
« no previous file with comments | « no previous file | src/codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698