Title: [140911] trunk/Source/WebCore
Revision
140911
Author
[email protected]
Date
2013-01-26 08:08:41 -0800 (Sat, 26 Jan 2013)

Log Message

[v8] prepare SerializedScriptValue for transition to Latin-1
https://bugs.webkit.org/show_bug.cgi?id=107655

Patch by Dan Carney <[email protected]> on 2013-01-26
Reviewed by Kentaro Hara.

No new tests. Covered by existing tests.

* bindings/v8/SerializedScriptValue.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (140910 => 140911)


--- trunk/Source/WebCore/ChangeLog	2013-01-26 10:01:32 UTC (rev 140910)
+++ trunk/Source/WebCore/ChangeLog	2013-01-26 16:08:41 UTC (rev 140911)
@@ -1,3 +1,14 @@
+2013-01-26  Dan Carney  <[email protected]>
+
+        [v8] prepare SerializedScriptValue for transition to Latin-1
+        https://bugs.webkit.org/show_bug.cgi?id=107655
+
+        Reviewed by Kentaro Hara.
+
+        No new tests. Covered by existing tests.
+
+        * bindings/v8/SerializedScriptValue.cpp:
+
 2013-01-26  Justin Schuh  <[email protected]>
 
         [CHROMIUM] Suppress more c4267 build warnings for Win64 targets

Modified: trunk/Source/WebCore/bindings/v8/SerializedScriptValue.cpp (140910 => 140911)


--- trunk/Source/WebCore/bindings/v8/SerializedScriptValue.cpp	2013-01-26 10:01:32 UTC (rev 140910)
+++ trunk/Source/WebCore/bindings/v8/SerializedScriptValue.cpp	2013-01-26 16:08:41 UTC (rev 140911)
@@ -315,15 +315,22 @@
 
     void writeOneByteString(v8::Handle<v8::String>& string)
     {
-        int length = string->Length();
-        ASSERT(length >= 0);
+        int stringLength = string->Length();
+        int utf8Length = string->Utf8Length();
+        ASSERT(stringLength >= 0 && utf8Length >= 0);
 
         append(StringTag);
-        doWriteUint32(static_cast<uint32_t>(length));
-        ensureSpace(length);
+        doWriteUint32(static_cast<uint32_t>(utf8Length));
+        ensureSpace(utf8Length);
 
-        string->WriteOneByte(byteAt(m_position), 0, length, v8StringWriteOptions());
-        m_position += length;
+        // ASCII fast path.
+        if (stringLength == utf8Length)
+            string->WriteOneByte(byteAt(m_position), 0, utf8Length, v8StringWriteOptions());
+        else {
+            char* buffer = reinterpret_cast<char*>(byteAt(m_position));
+            string->WriteUtf8(buffer, utf8Length, 0, v8StringWriteOptions());
+        }
+        m_position += utf8Length;
     }
 
     void writeUCharString(v8::Handle<v8::String>& string)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to