<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[183988] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/183988">183988</a></dd>
<dt>Author</dt> <dd>akling@apple.com</dd>
<dt>Date</dt> <dd>2015-05-08 01:44:23 -0700 (Fri, 08 May 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Optimize serialization of quoted JSON strings.
&lt;https://webkit.org/b/144754&gt;

Reviewed by Darin Adler.

Source/JavaScriptCore:

Optimized the serialization of quoted strings into JSON by moving the logic into
StringBuilder so it can make smarter decisions about buffering.

12% progression on Kraken/json-stringify-tinderbox (on my Mac Pro.)

* bytecompiler/NodesCodegen.cpp:
(JSC::ObjectPatternNode::toString): Use the new StringBuilder API.

* runtime/JSONObject.h:
* runtime/JSONObject.cpp:
(JSC::Stringifier::Holder::appendNextProperty):
(JSC::appendStringToStringBuilder): Deleted.
(JSC::appendQuotedJSONStringToBuilder): Deleted.
(JSC::Stringifier::appendQuotedString): Deleted.
(JSC::Stringifier::appendStringifiedValue): Moved the bulk of this logic
to StringBuilder and call that from here.

Source/WebKit2:

* NetworkProcess/cache/NetworkCacheEntry.cpp:
(WebKit::NetworkCache::Entry::asJSON): Use the new StringBuilder API.

Source/WTF:

Add a StringBuilder API for appending a quoted JSON string. This is used by
JSON.stringify() to implement efficient appending of strings while escaping
quotes, control characters and \uNNNN-style characters.

The main benefit comes from only doing a single buffer expansion up front,
instead of doing it every time we append something. The fudge factor is pretty
large, since the maximum number of output characters per input character is 6.

The first landing of this patch had two bugs in it:

- Made \uNNNN escapes uppercase hexadecimal instead of lowercase.
- Didn't preallocate enough space for 8-bit input strings.

Both were caught by existing tests on our bots, and both were due to last-minute
changes before landing. :/

* wtf/text/StringBuilder.cpp:
(WTF::appendQuotedJSONStringInternal):
(WTF::StringBuilder::appendQuotedJSONString):
* wtf/text/StringBuilder.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecompilerNodesCodegencpp">trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSONObjectcpp">trunk/Source/JavaScriptCore/runtime/JSONObject.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSONObjecth">trunk/Source/JavaScriptCore/runtime/JSONObject.h</a></li>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtftextStringBuildercpp">trunk/Source/WTF/wtf/text/StringBuilder.cpp</a></li>
<li><a href="#trunkSourceWTFwtftextStringBuilderh">trunk/Source/WTF/wtf/text/StringBuilder.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCacheEntrycpp">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheEntry.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (183987 => 183988)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-05-08 08:04:07 UTC (rev 183987)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-05-08 08:44:23 UTC (rev 183988)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2015-05-08  Andreas Kling  &lt;akling@apple.com&gt;
+
+        Optimize serialization of quoted JSON strings.
+        &lt;https://webkit.org/b/144754&gt;
+
+        Reviewed by Darin Adler.
+
+        Optimized the serialization of quoted strings into JSON by moving the logic into
+        StringBuilder so it can make smarter decisions about buffering.
+
+        12% progression on Kraken/json-stringify-tinderbox (on my Mac Pro.)
+
+        * bytecompiler/NodesCodegen.cpp:
+        (JSC::ObjectPatternNode::toString): Use the new StringBuilder API.
+
+        * runtime/JSONObject.h:
+        * runtime/JSONObject.cpp:
+        (JSC::Stringifier::Holder::appendNextProperty):
+        (JSC::appendStringToStringBuilder): Deleted.
+        (JSC::appendQuotedJSONStringToBuilder): Deleted.
+        (JSC::Stringifier::appendQuotedString): Deleted.
+        (JSC::Stringifier::appendStringifiedValue): Moved the bulk of this logic
+        to StringBuilder and call that from here.
+
</ins><span class="cx"> 2015-05-07  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r183961.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecompilerNodesCodegencpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp (183987 => 183988)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp        2015-05-08 08:04:07 UTC (rev 183987)
+++ trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp        2015-05-08 08:44:23 UTC (rev 183988)
</span><span class="lines">@@ -3087,7 +3087,7 @@
</span><span class="cx">     builder.append('{');
</span><span class="cx">     for (size_t i = 0; i &lt; m_targetPatterns.size(); i++) {
</span><span class="cx">         if (m_targetPatterns[i].wasString)
</span><del>-            appendQuotedJSONStringToBuilder(builder, m_targetPatterns[i].propertyName.string());
</del><ins>+            builder.appendQuotedJSONString(m_targetPatterns[i].propertyName.string());
</ins><span class="cx">         else
</span><span class="cx">             builder.append(m_targetPatterns[i].propertyName.string());
</span><span class="cx">         builder.append(':');
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSONObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSONObject.cpp (183987 => 183988)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSONObject.cpp        2015-05-08 08:04:07 UTC (rev 183987)
+++ trunk/Source/JavaScriptCore/runtime/JSONObject.cpp        2015-05-08 08:44:23 UTC (rev 183988)
</span><span class="lines">@@ -107,8 +107,6 @@
</span><span class="cx"> 
</span><span class="cx">     friend class Holder;
</span><span class="cx"> 
</span><del>-    static void appendQuotedString(StringBuilder&amp;, const String&amp;);
-
</del><span class="cx">     JSValue toJSON(JSValue, const PropertyNameForFunctionCall&amp;);
</span><span class="cx"> 
</span><span class="cx">     enum StringifyResult { StringifyFailed, StringifySucceeded, StringifyFailedDueToUndefinedValue };
</span><span class="lines">@@ -255,72 +253,6 @@
</span><span class="cx">     return Local&lt;Unknown&gt;(m_exec-&gt;vm(), jsString(m_exec, result.toString()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-template &lt;typename CharType&gt;
-static void appendStringToStringBuilder(StringBuilder&amp; builder, const CharType* data, int length)
-{
-    for (int i = 0; i &lt; length; ++i) {
-        int start = i;
-        while (i &lt; length &amp;&amp; (data[i] &gt; 0x1F &amp;&amp; data[i] != '&quot;' &amp;&amp; data[i] != '\\'))
-            ++i;
-        builder.append(data + start, i - start);
-        if (i &gt;= length)
-            break;
-        switch (data[i]) {
-        case '\t':
-            builder.append('\\');
-            builder.append('t');
-            break;
-        case '\r':
-            builder.append('\\');
-            builder.append('r');
-            break;
-        case '\n':
-            builder.append('\\');
-            builder.append('n');
-            break;
-        case '\f':
-            builder.append('\\');
-            builder.append('f');
-            break;
-        case '\b':
-            builder.append('\\');
-            builder.append('b');
-            break;
-        case '&quot;':
-            builder.append('\\');
-            builder.append('&quot;');
-            break;
-        case '\\':
-            builder.append('\\');
-            builder.append('\\');
-            break;
-        default:
-            static const char hexDigits[] = &quot;0123456789abcdef&quot;;
-            UChar ch = data[i];
-            LChar hex[] = { '\\', 'u', static_cast&lt;LChar&gt;(hexDigits[(ch &gt;&gt; 12) &amp; 0xF]), static_cast&lt;LChar&gt;(hexDigits[(ch &gt;&gt; 8) &amp; 0xF]), static_cast&lt;LChar&gt;(hexDigits[(ch &gt;&gt; 4) &amp; 0xF]), static_cast&lt;LChar&gt;(hexDigits[ch &amp; 0xF]) };
-            builder.append(hex, WTF_ARRAY_LENGTH(hex));
-            break;
-        }
-    }
-}
-
-void appendQuotedJSONStringToBuilder(StringBuilder&amp; builder, const String&amp; message)
-{
-    builder.append('&quot;');
-
-    if (message.is8Bit())
-        appendStringToStringBuilder(builder, message.characters8(), message.length());
-    else
-        appendStringToStringBuilder(builder, message.characters16(), message.length());
-
-    builder.append('&quot;');
-}
-
-void Stringifier::appendQuotedString(StringBuilder&amp; builder, const String&amp; value)
-{
-    appendQuotedJSONStringToBuilder(builder, value);
-}
-
</del><span class="cx"> inline JSValue Stringifier::toJSON(JSValue value, const PropertyNameForFunctionCall&amp; propertyName)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!m_exec-&gt;hadException());
</span><span class="lines">@@ -385,7 +317,7 @@
</span><span class="cx"> 
</span><span class="cx">     String stringValue;
</span><span class="cx">     if (value.getString(m_exec, stringValue)) {
</span><del>-        appendQuotedString(builder, stringValue);
</del><ins>+        builder.appendQuotedJSONString(stringValue);
</ins><span class="cx">         return StringifySucceeded;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -556,7 +488,7 @@
</span><span class="cx">         stringifier.startNewLine(builder);
</span><span class="cx"> 
</span><span class="cx">         // Append the property name.
</span><del>-        appendQuotedString(builder, propertyName.string());
</del><ins>+        builder.appendQuotedJSONString(propertyName.string());
</ins><span class="cx">         builder.append(':');
</span><span class="cx">         if (stringifier.willIndent())
</span><span class="cx">             builder.append(' ');
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSONObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSONObject.h (183987 => 183988)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSONObject.h        2015-05-08 08:04:07 UTC (rev 183987)
+++ trunk/Source/JavaScriptCore/runtime/JSONObject.h        2015-05-08 08:44:23 UTC (rev 183988)
</span><span class="lines">@@ -62,8 +62,6 @@
</span><span class="cx"> JS_EXPORT_PRIVATE JSValue JSONParse(ExecState*, const String&amp;);
</span><span class="cx"> JS_EXPORT_PRIVATE String JSONStringify(ExecState*, JSValue, unsigned indent);
</span><span class="cx"> 
</span><del>-JS_EXPORT_PRIVATE void appendQuotedJSONStringToBuilder(StringBuilder&amp;, const String&amp;);
-
</del><span class="cx">     
</span><span class="cx"> } // namespace JSC
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (183987 => 183988)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2015-05-08 08:04:07 UTC (rev 183987)
+++ trunk/Source/WTF/ChangeLog        2015-05-08 08:44:23 UTC (rev 183988)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2015-05-08  Andreas Kling  &lt;akling@apple.com&gt;
+
+        Optimize serialization of quoted JSON strings.
+        &lt;https://webkit.org/b/144754&gt;
+
+        Reviewed by Darin Adler.
+
+        Add a StringBuilder API for appending a quoted JSON string. This is used by
+        JSON.stringify() to implement efficient appending of strings while escaping
+        quotes, control characters and \uNNNN-style characters.
+
+        The main benefit comes from only doing a single buffer expansion up front,
+        instead of doing it every time we append something. The fudge factor is pretty
+        large, since the maximum number of output characters per input character is 6.
+
+        The first landing of this patch had two bugs in it:
+
+        - Made \uNNNN escapes uppercase hexadecimal instead of lowercase.
+        - Didn't preallocate enough space for 8-bit input strings.
+
+        Both were caught by existing tests on our bots, and both were due to last-minute
+        changes before landing. :/
+
+        * wtf/text/StringBuilder.cpp:
+        (WTF::appendQuotedJSONStringInternal):
+        (WTF::StringBuilder::appendQuotedJSONString):
+        * wtf/text/StringBuilder.h:
+
</ins><span class="cx"> 2015-05-07  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r183961.
</span></span></pre></div>
<a id="trunkSourceWTFwtftextStringBuildercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/StringBuilder.cpp (183987 => 183988)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/StringBuilder.cpp        2015-05-08 08:04:07 UTC (rev 183987)
+++ trunk/Source/WTF/wtf/text/StringBuilder.cpp        2015-05-08 08:44:23 UTC (rev 183988)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #include &quot;StringBuilder.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;IntegerToStringConversion.h&quot;
</span><ins>+#include &quot;MathExtras.h&quot;
</ins><span class="cx"> #include &quot;WTFString.h&quot;
</span><span class="cx"> #include &lt;wtf/dtoa.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -360,4 +361,88 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+template &lt;typename OutputCharacterType, typename InputCharacterType&gt;
+static void appendQuotedJSONStringInternal(OutputCharacterType*&amp; output, const InputCharacterType* input, unsigned length)
+{
+    for (const InputCharacterType* end = input + length; input != end; ++input) {
+        if (*input &gt; 0x1F &amp;&amp; *input != '&quot;' &amp;&amp; *input != '\\') {
+            *output++ = *input;
+            continue;
+        }
+        switch (*input) {
+        case '\t':
+            *output++ = '\\';
+            *output++ = 't';
+            break;
+        case '\r':
+            *output++ = '\\';
+            *output++ = 'r';
+            break;
+        case '\n':
+            *output++ = '\\';
+            *output++ = 'n';
+            break;
+        case '\f':
+            *output++ = '\\';
+            *output++ = 'f';
+            break;
+        case '\b':
+            *output++ = '\\';
+            *output++ = 'b';
+            break;
+        case '&quot;':
+            *output++ = '\\';
+            *output++ = '&quot;';
+            break;
+        case '\\':
+            *output++ = '\\';
+            *output++ = '\\';
+            break;
+        default:
+            ASSERT((*input &amp; 0xFF00) == 0);
+            static const char hexDigits[] = &quot;0123456789abcdef&quot;;
+            *output++ = '\\';
+            *output++ = 'u';
+            *output++ = '0';
+            *output++ = '0';
+            *output++ = static_cast&lt;LChar&gt;(hexDigits[(*input &gt;&gt; 4) &amp; 0xF]);
+            *output++ = static_cast&lt;LChar&gt;(hexDigits[*input &amp; 0xF]);
+            break;
+        }
+    }
+}
+
+void StringBuilder::appendQuotedJSONString(const String&amp; string)
+{
+    // Make sure we have enough buffer space to append this string without having
+    // to worry about reallocating in the middle.
+    // The 2 is for the '&quot;' quotes on each end.
+    // The 6 is for characters that need to be \uNNNN encoded.
+    size_t maximumCapacityRequired = length() + 2 + string.length() * 6;
+    RELEASE_ASSERT(maximumCapacityRequired &lt; std::numeric_limits&lt;unsigned&gt;::max());
+
+    if (is8Bit() &amp;&amp; !string.is8Bit())
+        allocateBufferUpConvert(m_bufferCharacters8, roundUpToPowerOfTwo(maximumCapacityRequired));
+    else
+        reserveCapacity(roundUpToPowerOfTwo(maximumCapacityRequired));
+
+    if (is8Bit()) {
+        ASSERT(string.is8Bit());
+        LChar* output = m_bufferCharacters8 + m_length;
+        *output++ = '&quot;';
+        appendQuotedJSONStringInternal(output, string.characters8(), string.length());
+        *output++ = '&quot;';
+        m_length = output - m_bufferCharacters8;
+    } else {
+        UChar* output = m_bufferCharacters16 + m_length;
+        *output++ = '&quot;';
+        if (string.is8Bit())
+            appendQuotedJSONStringInternal(output, string.characters8(), string.length());
+        else
+            appendQuotedJSONStringInternal(output, string.characters16(), string.length());
+        *output++ = '&quot;';
+        m_length = output - m_bufferCharacters16;
+    }
+}
+
</ins><span class="cx"> } // namespace WTF
</span></span></pre></div>
<a id="trunkSourceWTFwtftextStringBuilderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/StringBuilder.h (183987 => 183988)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/StringBuilder.h        2015-05-08 08:04:07 UTC (rev 183987)
+++ trunk/Source/WTF/wtf/text/StringBuilder.h        2015-05-08 08:44:23 UTC (rev 183988)
</span><span class="lines">@@ -159,6 +159,8 @@
</span><span class="cx">         append(U16_TRAIL(c));
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    WTF_EXPORT_PRIVATE void appendQuotedJSONString(const String&amp;);
+
</ins><span class="cx">     template&lt;unsigned charactersCount&gt;
</span><span class="cx">     ALWAYS_INLINE void appendLiteral(const char (&amp;characters)[charactersCount]) { append(characters, charactersCount - 1); }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (183987 => 183988)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-05-08 08:04:07 UTC (rev 183987)
+++ trunk/Source/WebKit2/ChangeLog        2015-05-08 08:44:23 UTC (rev 183988)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2015-05-08  Andreas Kling  &lt;akling@apple.com&gt;
+
+        Optimize serialization of quoted JSON strings.
+        &lt;https://webkit.org/b/144754&gt;
+
+        Reviewed by Darin Adler.
+
+        * NetworkProcess/cache/NetworkCacheEntry.cpp:
+        (WebKit::NetworkCache::Entry::asJSON): Use the new StringBuilder API.
+
</ins><span class="cx"> 2015-05-08  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r183945.
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCacheEntrycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheEntry.cpp (183987 => 183988)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheEntry.cpp        2015-05-08 08:04:07 UTC (rev 183987)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheEntry.cpp        2015-05-08 08:44:23 UTC (rev 183988)
</span><span class="lines">@@ -30,7 +30,6 @@
</span><span class="cx"> #include &quot;NetworkCacheCoders.h&quot;
</span><span class="cx"> #include &quot;NetworkCacheDecoder.h&quot;
</span><span class="cx"> #include &quot;NetworkCacheEncoder.h&quot;
</span><del>-#include &lt;JavaScriptCore/JSONObject.h&gt;
</del><span class="cx"> #include &lt;WebCore/ResourceRequest.h&gt;
</span><span class="cx"> #include &lt;WebCore/SharedBuffer.h&gt;
</span><span class="cx"> #include &lt;wtf/text/StringBuilder.h&gt;
</span><span class="lines">@@ -159,7 +158,7 @@
</span><span class="cx"> {
</span><span class="cx">     json.appendLiteral(&quot;{\n&quot;);
</span><span class="cx">     json.appendLiteral(&quot;\&quot;hash\&quot;: &quot;);
</span><del>-    JSC::appendQuotedJSONStringToBuilder(json, m_key.hashAsString());
</del><ins>+    json.appendQuotedJSONString(m_key.hashAsString());
</ins><span class="cx">     json.appendLiteral(&quot;,\n&quot;);
</span><span class="cx">     json.appendLiteral(&quot;\&quot;bodySize\&quot;: &quot;);
</span><span class="cx">     json.appendNumber(info.bodySize);
</span><span class="lines">@@ -168,16 +167,16 @@
</span><span class="cx">     json.appendNumber(info.worth);
</span><span class="cx">     json.appendLiteral(&quot;,\n&quot;);
</span><span class="cx">     json.appendLiteral(&quot;\&quot;partition\&quot;: &quot;);
</span><del>-    JSC::appendQuotedJSONStringToBuilder(json, m_key.partition());
</del><ins>+    json.appendQuotedJSONString(m_key.partition());
</ins><span class="cx">     json.appendLiteral(&quot;,\n&quot;);
</span><span class="cx">     json.appendLiteral(&quot;\&quot;timestamp\&quot;: &quot;);
</span><span class="cx">     json.appendNumber(std::chrono::duration_cast&lt;std::chrono::milliseconds&gt;(m_timeStamp.time_since_epoch()).count());
</span><span class="cx">     json.appendLiteral(&quot;,\n&quot;);
</span><span class="cx">     json.appendLiteral(&quot;\&quot;URL\&quot;: &quot;);
</span><del>-    JSC::appendQuotedJSONStringToBuilder(json, m_response.url().string());
</del><ins>+    json.appendQuotedJSONString(m_response.url().string());
</ins><span class="cx">     json.appendLiteral(&quot;,\n&quot;);
</span><span class="cx">     json.appendLiteral(&quot;\&quot;bodyHash\&quot;: &quot;);
</span><del>-    JSC::appendQuotedJSONStringToBuilder(json, info.bodyHash);
</del><ins>+    json.appendQuotedJSONString(info.bodyHash);
</ins><span class="cx">     json.appendLiteral(&quot;,\n&quot;);
</span><span class="cx">     json.appendLiteral(&quot;\&quot;bodyShareCount\&quot;: &quot;);
</span><span class="cx">     json.appendNumber(info.bodyShareCount);
</span><span class="lines">@@ -189,9 +188,9 @@
</span><span class="cx">             json.appendLiteral(&quot;,\n&quot;);
</span><span class="cx">         firstHeader = false;
</span><span class="cx">         json.appendLiteral(&quot;    &quot;);
</span><del>-        JSC::appendQuotedJSONStringToBuilder(json, header.key);
</del><ins>+        json.appendQuotedJSONString(header.key);
</ins><span class="cx">         json.appendLiteral(&quot;: &quot;);
</span><del>-        JSC::appendQuotedJSONStringToBuilder(json, header.value);
</del><ins>+        json.appendQuotedJSONString(header.value);
</ins><span class="cx">     }
</span><span class="cx">     json.appendLiteral(&quot;\n}\n&quot;);
</span><span class="cx">     json.appendLiteral(&quot;}&quot;);
</span></span></pre>
</div>
</div>

</body>
</html>