Skip to content

Commit 202025b

Browse files
Dan Carneywebkit-commit-queue
authored andcommitted
[v8] prepare SerializedScriptValue for transition to Latin-1
https://bugs.webkit.org/show_bug.cgi?id=107655 Patch by Dan Carney <dcarney@google.com> on 2013-01-26 Reviewed by Kentaro Hara. No new tests. Covered by existing tests. * bindings/v8/SerializedScriptValue.cpp: Canonical link: https://commits.webkit.org/126220@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@140911 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 837df1a commit 202025b

2 files changed

Lines changed: 25 additions & 7 deletions

File tree

Source/WebCore/ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2013-01-26 Dan Carney <dcarney@google.com>
2+
3+
[v8] prepare SerializedScriptValue for transition to Latin-1
4+
https://bugs.webkit.org/show_bug.cgi?id=107655
5+
6+
Reviewed by Kentaro Hara.
7+
8+
No new tests. Covered by existing tests.
9+
10+
* bindings/v8/SerializedScriptValue.cpp:
11+
112
2013-01-26 Justin Schuh <jschuh@chromium.org>
213

314
[CHROMIUM] Suppress more c4267 build warnings for Win64 targets

Source/WebCore/bindings/v8/SerializedScriptValue.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -315,15 +315,22 @@ class Writer {
315315

316316
void writeOneByteString(v8::Handle<v8::String>& string)
317317
{
318-
int length = string->Length();
319-
ASSERT(length >= 0);
318+
int stringLength = string->Length();
319+
int utf8Length = string->Utf8Length();
320+
ASSERT(stringLength >= 0 && utf8Length >= 0);
320321

321322
append(StringTag);
322-
doWriteUint32(static_cast<uint32_t>(length));
323-
ensureSpace(length);
324-
325-
string->WriteOneByte(byteAt(m_position), 0, length, v8StringWriteOptions());
326-
m_position += length;
323+
doWriteUint32(static_cast<uint32_t>(utf8Length));
324+
ensureSpace(utf8Length);
325+
326+
// ASCII fast path.
327+
if (stringLength == utf8Length)
328+
string->WriteOneByte(byteAt(m_position), 0, utf8Length, v8StringWriteOptions());
329+
else {
330+
char* buffer = reinterpret_cast<char*>(byteAt(m_position));
331+
string->WriteUtf8(buffer, utf8Length, 0, v8StringWriteOptions());
332+
}
333+
m_position += utf8Length;
327334
}
328335

329336
void writeUCharString(v8::Handle<v8::String>& string)

0 commit comments

Comments
 (0)