Commit e0ef8d05 authored by Yang Guo's avatar Yang Guo Committed by Commit Bot

Flatten on v8::String::{Write*,Utf8Length} regardless of hint option.

I suspect that this is a premature optimization that we don't actually
need.

R=leszeks@chromium.org
BUG: v8:6780

Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Change-Id: Icdec54cb749897164f287f5a69c7f76a540b45c4
Reviewed-on: https://chromium-review.googlesource.com/968261
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52020}
parent a33353a0
...@@ -5578,6 +5578,7 @@ static int Utf8Length(i::String* str, i::Isolate* isolate) { ...@@ -5578,6 +5578,7 @@ static int Utf8Length(i::String* str, i::Isolate* isolate) {
int String::Utf8Length() const { int String::Utf8Length() const {
i::Handle<i::String> str = Utils::OpenHandle(this); i::Handle<i::String> str = Utils::OpenHandle(this);
str = i::String::Flatten(str);
i::Isolate* isolate = str->GetIsolate(); i::Isolate* isolate = str->GetIsolate();
return v8::Utf8Length(*str, isolate); return v8::Utf8Length(*str, isolate);
} }
...@@ -5791,9 +5792,7 @@ int String::WriteUtf8(char* buffer, ...@@ -5791,9 +5792,7 @@ int String::WriteUtf8(char* buffer,
i::Isolate* isolate = str->GetIsolate(); i::Isolate* isolate = str->GetIsolate();
LOG_API(isolate, String, WriteUtf8); LOG_API(isolate, String, WriteUtf8);
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
if (options & HINT_MANY_WRITES_EXPECTED) { str = i::String::Flatten(str); // Flatten the string for efficiency.
str = i::String::Flatten(str); // Flatten the string for efficiency.
}
const int string_length = str->length(); const int string_length = str->length();
bool write_null = !(options & NO_NULL_TERMINATION); bool write_null = !(options & NO_NULL_TERMINATION);
bool replace_invalid_utf8 = (options & REPLACE_INVALID_UTF8); bool replace_invalid_utf8 = (options & REPLACE_INVALID_UTF8);
...@@ -5845,11 +5844,7 @@ static inline int WriteHelper(const String* string, ...@@ -5845,11 +5844,7 @@ static inline int WriteHelper(const String* string,
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
DCHECK(start >= 0 && length >= -1); DCHECK(start >= 0 && length >= -1);
i::Handle<i::String> str = Utils::OpenHandle(string); i::Handle<i::String> str = Utils::OpenHandle(string);
if (options & String::HINT_MANY_WRITES_EXPECTED) { str = i::String::Flatten(str);
// Flatten the string for efficiency. This applies whether we are
// using StringCharacterStream or Get(i) to access the characters.
str = i::String::Flatten(str);
}
int end = start + length; int end = start + length;
if ((length == -1) || (length > str->length() - start) ) if ((length == -1) || (length > str->length() - start) )
end = str->length(); end = str->length();
......
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