| Index: runtime/vm/object.cc
|
| diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
|
| index cfd08f6c964c7df53dd6dcd9cfd761f14f4b44e4..e97eccc5442aeece7bf153c0c1de817b383259dc 100644
|
| --- a/runtime/vm/object.cc
|
| +++ b/runtime/vm/object.cc
|
| @@ -19857,14 +19857,14 @@ RawString* String::FromUTF8(const uint8_t* utf8_array,
|
| if (len > 0) {
|
| NoSafepointScope no_safepoint;
|
| Utf8::DecodeToLatin1(utf8_array, array_len,
|
| - OneByteString::CharAddr(strobj, 0), len);
|
| + OneByteString::DataStart(strobj), len);
|
| }
|
| return strobj.raw();
|
| }
|
| ASSERT((type == Utf8::kBMP) || (type == Utf8::kSupplementary));
|
| const String& strobj = String::Handle(TwoByteString::New(len, space));
|
| NoSafepointScope no_safepoint;
|
| - Utf8::DecodeToUTF16(utf8_array, array_len, TwoByteString::CharAddr(strobj, 0),
|
| + Utf8::DecodeToUTF16(utf8_array, array_len, TwoByteString::DataStart(strobj),
|
| len);
|
| return strobj.raw();
|
| }
|
| @@ -20301,29 +20301,6 @@ RawString* String::SubString(Thread* thread,
|
| }
|
|
|
| const char* String::ToCString() const {
|
| - if (IsOneByteString()) {
|
| - // Quick conversion if OneByteString contains only ASCII characters.
|
| - intptr_t len = Length();
|
| - if (len == 0) {
|
| - return "";
|
| - }
|
| - Zone* zone = Thread::Current()->zone();
|
| - uint8_t* result = zone->Alloc<uint8_t>(len + 1);
|
| - NoSafepointScope no_safepoint;
|
| - const uint8_t* original_str = OneByteString::CharAddr(*this, 0);
|
| - for (intptr_t i = 0; i < len; i++) {
|
| - if (original_str[i] <= Utf8::kMaxOneByteChar) {
|
| - result[i] = original_str[i];
|
| - } else {
|
| - len = -1;
|
| - break;
|
| - }
|
| - }
|
| - if (len > 0) {
|
| - result[len] = 0;
|
| - return reinterpret_cast<const char*>(result);
|
| - }
|
| - }
|
| const intptr_t len = Utf8::Length(*this);
|
| Zone* zone = Thread::Current()->zone();
|
| uint8_t* result = zone->Alloc<uint8_t>(len + 1);
|
| @@ -20333,25 +20310,6 @@ const char* String::ToCString() const {
|
| }
|
|
|
| char* String::ToMallocCString() const {
|
| - if (IsOneByteString()) {
|
| - // Quick conversion if OneByteString contains only ASCII characters.
|
| - intptr_t len = Length();
|
| - uint8_t* result = reinterpret_cast<uint8_t*>(malloc(len + 1));
|
| - NoSafepointScope no_safepoint;
|
| - const uint8_t* original_str = OneByteString::CharAddr(*this, 0);
|
| - for (intptr_t i = 0; i < len; i++) {
|
| - if (original_str[i] <= Utf8::kMaxOneByteChar) {
|
| - result[i] = original_str[i];
|
| - } else {
|
| - len = -1;
|
| - break;
|
| - }
|
| - }
|
| - if (len > 0) {
|
| - result[len] = 0;
|
| - return reinterpret_cast<char*>(result);
|
| - }
|
| - }
|
| const intptr_t len = Utf8::Length(*this);
|
| uint8_t* result = reinterpret_cast<uint8_t*>(malloc(len + 1));
|
| ToUTF8(result, len);
|
| @@ -20646,7 +20604,7 @@ RawOneByteString* OneByteString::New(const uint8_t* characters,
|
| const String& result = String::Handle(OneByteString::New(len, space));
|
| if (len > 0) {
|
| NoSafepointScope no_safepoint;
|
| - memmove(CharAddr(result, 0), characters, len);
|
| + memmove(DataStart(result), characters, len);
|
| }
|
| return OneByteString::raw(result);
|
| }
|
| @@ -20690,7 +20648,7 @@ RawOneByteString* OneByteString::New(const String& other_one_byte_string,
|
| ASSERT(other_one_byte_string.IsOneByteString());
|
| if (other_len > 0) {
|
| NoSafepointScope no_safepoint;
|
| - memmove(OneByteString::CharAddr(result, 0),
|
| + memmove(OneByteString::DataStart(result),
|
| OneByteString::CharAddr(other_one_byte_string, other_start_index),
|
| other_len);
|
| }
|
| @@ -20705,7 +20663,7 @@ RawOneByteString* OneByteString::New(const TypedData& other_typed_data,
|
| ASSERT(other_typed_data.ElementSizeInBytes() == 1);
|
| if (other_len > 0) {
|
| NoSafepointScope no_safepoint;
|
| - memmove(OneByteString::CharAddr(result, 0),
|
| + memmove(OneByteString::DataStart(result),
|
| other_typed_data.DataAddr(other_start_index), other_len);
|
| }
|
| return OneByteString::raw(result);
|
| @@ -20719,7 +20677,7 @@ RawOneByteString* OneByteString::New(const ExternalTypedData& other_typed_data,
|
| ASSERT(other_typed_data.ElementSizeInBytes() == 1);
|
| if (other_len > 0) {
|
| NoSafepointScope no_safepoint;
|
| - memmove(OneByteString::CharAddr(result, 0),
|
| + memmove(OneByteString::DataStart(result),
|
| other_typed_data.DataAddr(other_start_index), other_len);
|
| }
|
| return OneByteString::raw(result);
|
| @@ -20869,7 +20827,7 @@ RawTwoByteString* TwoByteString::New(const uint16_t* utf16_array,
|
| const String& result = String::Handle(TwoByteString::New(array_len, space));
|
| {
|
| NoSafepointScope no_safepoint;
|
| - memmove(CharAddr(result, 0), utf16_array, (array_len * 2));
|
| + memmove(DataStart(result), utf16_array, (array_len * 2));
|
| }
|
| return TwoByteString::raw(result);
|
| }
|
| @@ -20912,7 +20870,7 @@ RawTwoByteString* TwoByteString::New(const TypedData& other_typed_data,
|
| const String& result = String::Handle(TwoByteString::New(other_len, space));
|
| if (other_len > 0) {
|
| NoSafepointScope no_safepoint;
|
| - memmove(TwoByteString::CharAddr(result, 0),
|
| + memmove(TwoByteString::DataStart(result),
|
| other_typed_data.DataAddr(other_start_index),
|
| other_len * sizeof(uint16_t));
|
| }
|
| @@ -20926,7 +20884,7 @@ RawTwoByteString* TwoByteString::New(const ExternalTypedData& other_typed_data,
|
| const String& result = String::Handle(TwoByteString::New(other_len, space));
|
| if (other_len > 0) {
|
| NoSafepointScope no_safepoint;
|
| - memmove(TwoByteString::CharAddr(result, 0),
|
| + memmove(TwoByteString::DataStart(result),
|
| other_typed_data.DataAddr(other_start_index),
|
| other_len * sizeof(uint16_t));
|
| }
|
|
|