Commit 4c7620dc authored by antonm@chromium.org's avatar antonm@chromium.org

Use WriteToFlat instead of to C strings methods as WriteToFlat performs notably

better for various kinds of strings.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3103 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 8b33cb71
...@@ -754,7 +754,8 @@ bool String::MakeExternal(v8::String::ExternalStringResource* resource) { ...@@ -754,7 +754,8 @@ bool String::MakeExternal(v8::String::ExternalStringResource* resource) {
if (FLAG_enable_slow_asserts) { if (FLAG_enable_slow_asserts) {
// Assert that the resource and the string are equivalent. // Assert that the resource and the string are equivalent.
ASSERT(static_cast<size_t>(this->length()) == resource->length()); ASSERT(static_cast<size_t>(this->length()) == resource->length());
SmartPointer<uc16> smart_chars = this->ToWideCString(); SmartPointer<uc16> smart_chars(NewArray<uc16>(this->length()));
String::WriteToFlat(this, *smart_chars, 0, this->length());
ASSERT(memcmp(*smart_chars, ASSERT(memcmp(*smart_chars,
resource->data(), resource->data(),
resource->length() * sizeof(**smart_chars)) == 0); resource->length() * sizeof(**smart_chars)) == 0);
...@@ -797,7 +798,8 @@ bool String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) { ...@@ -797,7 +798,8 @@ bool String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) {
if (FLAG_enable_slow_asserts) { if (FLAG_enable_slow_asserts) {
// Assert that the resource and the string are equivalent. // Assert that the resource and the string are equivalent.
ASSERT(static_cast<size_t>(this->length()) == resource->length()); ASSERT(static_cast<size_t>(this->length()) == resource->length());
SmartPointer<char> smart_chars = this->ToCString(); SmartPointer<char> smart_chars(NewArray<char>(this->length()));
String::WriteToFlat(this, *smart_chars, 0, this->length());
ASSERT(memcmp(*smart_chars, ASSERT(memcmp(*smart_chars,
resource->data(), resource->data(),
resource->length()*sizeof(**smart_chars)) == 0); resource->length()*sizeof(**smart_chars)) == 0);
......
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