<!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>[161840] 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/161840">161840</a></dd>
<dt>Author</dt> <dd>darin@apple.com</dd>
<dt>Date</dt> <dd>2014-01-12 15:23:44 -0800 (Sun, 12 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Reduce use of String::characters
https://bugs.webkit.org/show_bug.cgi?id=126854

Reviewed by Sam Weinig.

Source/JavaScriptCore:

* API/JSValueRef.cpp:
(JSValueMakeFromJSONString): Use characters16 instead of characters for 16-bit case.
Had to remove length check because an empty string could be either 8 bit or 16 bit.
Don't need a null string check before calling is8Bit because JSStringRef can't hold
a null string.

* bindings/ScriptValue.cpp:
(Deprecated::jsToInspectorValue): Use the existing string here instead of creating
a new one by calling characters and length on the old string. I think this may be
left over from when string types were not the same in JavaScriptCore and WebCore.
Also rewrite the property names loop to use modern for syntax and fewer locals.

* inspector/InspectorValues.cpp:
(Inspector::escapeChar): Changed to use appendLiteral instead of hard-coding string
lengths. Moved handling of &quot;&lt;&quot; and &quot;&gt;&quot; in here instead of at the call site.
(Inspector::doubleQuoteString): Simplify the code so there is no use of characters
and length. This is still an inefficient way of doing this job and could use a rethink.

* runtime/DatePrototype.cpp:
(JSC::formatLocaleDate): Use RetainPtr, createCFString, and the conversion from
CFStringRef to WTF::String to remove a lot of unneeded code.

* runtime/Identifier.h: Removed unneeded Identifier::characters function.

* runtime/JSStringBuilder.h:
(JSC::JSStringBuilder::append): Use characters16 instead of characters function here,
since we have already checked is8Bit above.

Source/WebCore:

* bindings/objc/WebScriptObject.mm:
(+[WebScriptObject _convertValueToObjcValue:JSC::originRootObject:rootObject:]):
Get rid of unneeded code to turn a WTF::String into an NSString, since that's
built into the WTF::String class.

* editing/CompositeEditCommand.cpp:
(WebCore::containsOnlyWhitespace): Use WTF::String's [] operator instead of
an explicit call to the characters function. Small performance cost.
* editing/TypingCommand.cpp:
(WebCore::TypingCommand::insertText): Ditto.

* editing/VisibleUnits.cpp:
(WebCore::startOfParagraph): Use reverseFind instead of writing our own loop.
(WebCore::endOfParagraph): Use find instead of writing our own loop.

* html/parser/HTMLParserIdioms.cpp:
(WebCore::stripLeadingAndTrailingHTMLSpaces): Use characters16 instead of
characters since we have already checked is8Bit.
(WebCore::parseHTMLNonNegativeInteger): Ditto. Replace the length check with
a check of isNull since a zero length string could be 8 bit, but it's not
safe to call is8Bit on a null WTF::String. (That should probably be fixed.)

* inspector/ContentSearchUtils.cpp:
(WebCore::ContentSearchUtils::createSearchRegexSource): Use StringBuilder
instead of String in code that builds up a string one character at a time.
The old way was ridiculously slow because it allocated a new string for every
character; the new way still isn't all that efficient, but it's better. Also
changed to use strchr instead of WTF::String::find for special characters.

* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyle::newLineAndWhitespaceDelimiters): Use WTF::String's
[] operator instead of an explicit call to the characters function.
* inspector/InspectorStyleTextEditor.cpp:
(WebCore::InspectorStyleTextEditor::insertProperty): Ditto.
(WebCore::InspectorStyleTextEditor::internalReplaceProperty): Ditto.
* platform/Length.cpp:
(WebCore::newCoordsArray): Ditto.

* platform/LinkHash.cpp:
(WebCore::visitedLinkHash): Use characters16 instead of characters since
we have already checked is8Bit. Replace the length check with a check of
isNull (as above in parseHTMLNonNegativeInteger).

* platform/graphics/Color.cpp:
(WebCore::Color::parseHexColor): Use characters16 since we already checked is8Bit.
(WebCore::Color::Color): Ditto.

* platform/graphics/TextRun.h:
(WebCore::TextRun::TextRun): Use characters16 instead of characters since
we have already checked is8Bit. Replace the length check with a check of
isNull (as above in parseHTMLNonNegativeInteger).

* platform/text/TextEncodingRegistry.cpp:
(WebCore::atomicCanonicalTextEncodingName): Use characters16 instead of
characters since we already checked is8Bit. Also use isEmpty instead of !length.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::constructTextRun): Use characters16 instead of characters
since we have already checked is8Bit. Replace the length check with a check of
isNull (as above in parseHTMLNonNegativeInteger).

* rendering/RenderCombineText.cpp:
(WebCore::RenderCombineText::width): Check for zero length instead of checking
for null characters.

* svg/SVGFontElement.cpp:
(WebCore::SVGFontElement::registerLigaturesInGlyphCache): Rewrite ligatures
for loop and give local variables a better name. Construct the substring with
the substring function. Still a really inefficient approach -- allocating a new
string for every character is absurdly expensive.

* xml/XPathFunctions.cpp:
(WebCore::XPath::FunId::evaluate): Use String instead of StringBuilder. Still
not all that efficient, but better than before. Use substring to construct the
substring.

* xml/XPathNodeSet.h: Added begin and end functions so we can use a C++11 for
loop with this class.

Source/WTF:

* wtf/text/StringImpl.cpp:
(WTF::StringImpl::replace): Use characters16 here since is8Bit was already checked.
* wtf/text/WTFString.h:
(WTF::String::isAllSpecialCharacters): Use characters16 here since is8Bit was
already checked. Also renamed &quot;len&quot; to &quot;length&quot;.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreAPIJSValueRefcpp">trunk/Source/JavaScriptCore/API/JSValueRef.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorebindingsScriptValuecpp">trunk/Source/JavaScriptCore/bindings/ScriptValue.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorInspectorValuescpp">trunk/Source/JavaScriptCore/inspector/InspectorValues.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeDatePrototypecpp">trunk/Source/JavaScriptCore/runtime/DatePrototype.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeIdentifierh">trunk/Source/JavaScriptCore/runtime/Identifier.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSStringBuilderh">trunk/Source/JavaScriptCore/runtime/JSStringBuilder.h</a></li>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtftextStringImplcpp">trunk/Source/WTF/wtf/text/StringImpl.cpp</a></li>
<li><a href="#trunkSourceWTFwtftextWTFStringh">trunk/Source/WTF/wtf/text/WTFString.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsobjcWebScriptObjectmm">trunk/Source/WebCore/bindings/objc/WebScriptObject.mm</a></li>
<li><a href="#trunkSourceWebCoreeditingCompositeEditCommandcpp">trunk/Source/WebCore/editing/CompositeEditCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingTypingCommandcpp">trunk/Source/WebCore/editing/TypingCommand.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingVisibleUnitscpp">trunk/Source/WebCore/editing/VisibleUnits.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlparserHTMLParserIdiomscpp">trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorContentSearchUtilscpp">trunk/Source/WebCore/inspector/ContentSearchUtils.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorStyleSheetcpp">trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorStyleTextEditorcpp">trunk/Source/WebCore/inspector/InspectorStyleTextEditor.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformLengthcpp">trunk/Source/WebCore/platform/Length.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformLinkHashcpp">trunk/Source/WebCore/platform/LinkHash.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsColorcpp">trunk/Source/WebCore/platform/graphics/Color.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsTextRunh">trunk/Source/WebCore/platform/graphics/TextRun.h</a></li>
<li><a href="#trunkSourceWebCoreplatformtextTextEncodingRegistrycpp">trunk/Source/WebCore/platform/text/TextEncodingRegistry.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockcpp">trunk/Source/WebCore/rendering/RenderBlock.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderCombineTextcpp">trunk/Source/WebCore/rendering/RenderCombineText.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGFontElementcpp">trunk/Source/WebCore/svg/SVGFontElement.cpp</a></li>
<li><a href="#trunkSourceWebCorexmlXPathFunctionscpp">trunk/Source/WebCore/xml/XPathFunctions.cpp</a></li>
<li><a href="#trunkSourceWebCorexmlXPathNodeSeth">trunk/Source/WebCore/xml/XPathNodeSet.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreAPIJSValueRefcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/API/JSValueRef.cpp (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/API/JSValueRef.cpp        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/JavaScriptCore/API/JSValueRef.cpp        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -323,11 +323,11 @@
</span><span class="cx">     APIEntryShim entryShim(exec);
</span><span class="cx">     String str = string-&gt;string();
</span><span class="cx">     unsigned length = str.length();
</span><del>-    if (length &amp;&amp; str.is8Bit()) {
</del><ins>+    if (str.is8Bit()) {
</ins><span class="cx">         LiteralParser&lt;LChar&gt; parser(exec, str.characters8(), length, StrictJSON);
</span><span class="cx">         return toRef(exec, parser.tryLiteralParse());
</span><span class="cx">     }
</span><del>-    LiteralParser&lt;UChar&gt; parser(exec, str.characters(), length, StrictJSON);
</del><ins>+    LiteralParser&lt;UChar&gt; parser(exec, str.characters16(), length, StrictJSON);
</ins><span class="cx">     return toRef(exec, parser.tryLiteralParse());
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/JavaScriptCore/ChangeLog        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2014-01-12  Darin Adler  &lt;darin@apple.com&gt;
+
+        Reduce use of String::characters
+        https://bugs.webkit.org/show_bug.cgi?id=126854
+
+        Reviewed by Sam Weinig.
+
+        * API/JSValueRef.cpp:
+        (JSValueMakeFromJSONString): Use characters16 instead of characters for 16-bit case.
+        Had to remove length check because an empty string could be either 8 bit or 16 bit.
+        Don't need a null string check before calling is8Bit because JSStringRef can't hold
+        a null string.
+
+        * bindings/ScriptValue.cpp:
+        (Deprecated::jsToInspectorValue): Use the existing string here instead of creating
+        a new one by calling characters and length on the old string. I think this may be
+        left over from when string types were not the same in JavaScriptCore and WebCore.
+        Also rewrite the property names loop to use modern for syntax and fewer locals.
+
+        * inspector/InspectorValues.cpp:
+        (Inspector::escapeChar): Changed to use appendLiteral instead of hard-coding string
+        lengths. Moved handling of &quot;&lt;&quot; and &quot;&gt;&quot; in here instead of at the call site.
+        (Inspector::doubleQuoteString): Simplify the code so there is no use of characters
+        and length. This is still an inefficient way of doing this job and could use a rethink.
+
+        * runtime/DatePrototype.cpp:
+        (JSC::formatLocaleDate): Use RetainPtr, createCFString, and the conversion from
+        CFStringRef to WTF::String to remove a lot of unneeded code.
+
+        * runtime/Identifier.h: Removed unneeded Identifier::characters function.
+
+        * runtime/JSStringBuilder.h:
+        (JSC::JSStringBuilder::append): Use characters16 instead of characters function here,
+        since we have already checked is8Bit above.
+
</ins><span class="cx"> 2014-01-12  Andy Estes  &lt;aestes@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [iOS] Enable the JSC Objective-C API
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebindingsScriptValuecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bindings/ScriptValue.cpp (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bindings/ScriptValue.cpp        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/JavaScriptCore/bindings/ScriptValue.cpp        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -115,10 +115,8 @@
</span><span class="cx">         return InspectorBasicValue::create(value.asBoolean());
</span><span class="cx">     if (value.isNumber())
</span><span class="cx">         return InspectorBasicValue::create(value.asNumber());
</span><del>-    if (value.isString()) {
-        String s = value.getString(scriptState);
-        return InspectorString::create(String(s.characters(), s.length()));
-    }
</del><ins>+    if (value.isString())
+        return InspectorString::create(value.getString(scriptState));
</ins><span class="cx"> 
</span><span class="cx">     if (value.isObject()) {
</span><span class="cx">         if (isJSArray(value)) {
</span><span class="lines">@@ -138,13 +136,11 @@
</span><span class="cx">         JSObject* object = value.getObject();
</span><span class="cx">         PropertyNameArray propertyNames(scriptState);
</span><span class="cx">         object-&gt;methodTable()-&gt;getOwnPropertyNames(object, scriptState, propertyNames, ExcludeDontEnumProperties);
</span><del>-        for (size_t i = 0; i &lt; propertyNames.size(); i++) {
-            const Identifier&amp; name =  propertyNames[i];
-            JSValue propertyValue = object-&gt;get(scriptState, name);
-            RefPtr&lt;InspectorValue&gt; inspectorValue = jsToInspectorValue(scriptState, propertyValue, maxDepth);
</del><ins>+        for (auto&amp; name : propertyNames) {
+            RefPtr&lt;InspectorValue&gt; inspectorValue = jsToInspectorValue(scriptState, object-&gt;get(scriptState, name), maxDepth);
</ins><span class="cx">             if (!inspectorValue)
</span><span class="cx">                 return nullptr;
</span><del>-            inspectorObject-&gt;setValue(String(name.characters(), name.length()), inspectorValue);
</del><ins>+            inspectorObject-&gt;setValue(name.string(), inspectorValue);
</ins><span class="cx">         }
</span><span class="cx">         return inspectorObject;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorInspectorValuescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/InspectorValues.cpp (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/InspectorValues.cpp        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/JavaScriptCore/inspector/InspectorValues.cpp        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -446,14 +446,17 @@
</span><span class="cx"> 
</span><span class="cx"> inline bool escapeChar(UChar c, StringBuilder* dst)
</span><span class="cx"> {
</span><ins>+    // Must escape &lt; and &gt; to prevent script execution.
</ins><span class="cx">     switch (c) {
</span><del>-    case '\b': dst-&gt;append(&quot;\\b&quot;, 2); break;
-    case '\f': dst-&gt;append(&quot;\\f&quot;, 2); break;
-    case '\n': dst-&gt;append(&quot;\\n&quot;, 2); break;
-    case '\r': dst-&gt;append(&quot;\\r&quot;, 2); break;
-    case '\t': dst-&gt;append(&quot;\\t&quot;, 2); break;
-    case '\\': dst-&gt;append(&quot;\\\\&quot;, 2); break;
-    case '&quot;': dst-&gt;append(&quot;\\\&quot;&quot;, 2); break;
</del><ins>+    case '\b': dst-&gt;appendLiteral(&quot;\\b&quot;); break;
+    case '\f': dst-&gt;appendLiteral(&quot;\\f&quot;); break;
+    case '\n': dst-&gt;appendLiteral(&quot;\\n&quot;); break;
+    case '\r': dst-&gt;appendLiteral(&quot;\\r&quot;); break;
+    case '\t': dst-&gt;appendLiteral(&quot;\\t&quot;); break;
+    case '\\': dst-&gt;appendLiteral(&quot;\\\\&quot;); break;
+    case '&quot;': dst-&gt;appendLiteral(&quot;\\\&quot;&quot;); break;
+    case '&lt;': dst-&gt;appendLiteral(&quot;\\u003C&quot;); break;
+    case '&gt;': dst-&gt;appendLiteral(&quot;\\u003E&quot;); break;
</ins><span class="cx">     default:
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="lines">@@ -466,15 +469,13 @@
</span><span class="cx">     for (unsigned i = 0; i &lt; str.length(); ++i) {
</span><span class="cx">         UChar c = str[i];
</span><span class="cx">         if (!escapeChar(c, dst)) {
</span><del>-            if (c &lt; 32 || c &gt; 126 || c == '&lt;' || c == '&gt;') {
-                // 1. Escaping &lt;, &gt; to prevent script execution.
-                // 2. Technically, we could also pass through c &gt; 126 as UTF8, but this
-                //    is also optional.  It would also be a pain to implement here.
-                unsigned int symbol = static_cast&lt;unsigned int&gt;(c);
-                String symbolCode = String::format(&quot;\\u%04X&quot;, symbol);
-                dst-&gt;append(symbolCode.characters(), symbolCode.length());
-            } else
</del><ins>+            // We could format c &gt; 126 as UTF-8 instead of escaping them.
+            if (c &gt;= 32 || c &lt;= 126)
</ins><span class="cx">                 dst-&gt;append(c);
</span><ins>+            else {
+                // FIXME: Way too slow to do this by creating and destroying a string each time.
+                dst-&gt;append(String::format(&quot;\\u%04X&quot;, static_cast&lt;unsigned&gt;(c)));
+            }
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     dst-&gt;append('&quot;');
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeDatePrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/DatePrototype.cpp (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/DatePrototype.cpp        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/JavaScriptCore/runtime/DatePrototype.cpp        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -162,33 +162,14 @@
</span><span class="cx">     else if (format != LocaleDate &amp;&amp; !exec-&gt;argument(0).isUndefined())
</span><span class="cx">         timeStyle = styleFromArgString(arg0String, timeStyle);
</span><span class="cx"> 
</span><del>-    CFLocaleRef locale = CFLocaleCopyCurrent();
-    CFDateFormatterRef formatter = CFDateFormatterCreate(0, locale, dateStyle, timeStyle);
-    CFRelease(locale);
</del><ins>+    RetainPtr&lt;CFDateFormatterRef&gt; formatter = adoptCF(CFDateFormatterCreate(kCFAllocatorDefault, adoptCF(CFLocaleCopyCurrent()).get(), dateStyle, timeStyle));
</ins><span class="cx"> 
</span><del>-    if (useCustomFormat) {
-        CFStringRef customFormatCFString = CFStringCreateWithCharacters(0, customFormatString.characters(), customFormatString.length());
-        CFDateFormatterSetFormat(formatter, customFormatCFString);
-        CFRelease(customFormatCFString);
-    }
</del><ins>+    if (useCustomFormat)
+        CFDateFormatterSetFormat(formatter.get(), customFormatString.createCFString().get());
</ins><span class="cx"> 
</span><del>-    CFStringRef string = CFDateFormatterCreateStringWithAbsoluteTime(0, formatter, floor(timeInMilliseconds / msPerSecond) - kCFAbsoluteTimeIntervalSince1970);
</del><ins>+    RetainPtr&lt;CFStringRef&gt; string = adoptCF(CFDateFormatterCreateStringWithAbsoluteTime(kCFAllocatorDefault, formatter.get(), floor(timeInMilliseconds / msPerSecond) - kCFAbsoluteTimeIntervalSince1970));
</ins><span class="cx"> 
</span><del>-    CFRelease(formatter);
-
-    // We truncate the string returned from CFDateFormatter if it's absurdly long (&gt; 200 characters).
-    // That's not great error handling, but it just won't happen so it doesn't matter.
-    UChar buffer[200];
-    const size_t bufferLength = WTF_ARRAY_LENGTH(buffer);
-    size_t length = CFStringGetLength(string);
-    ASSERT(length &lt;= bufferLength);
-    if (length &gt; bufferLength)
-        length = bufferLength;
-    CFStringGetCharacters(string, CFRangeMake(0, length), buffer);
-
-    CFRelease(string);
-
-    return jsNontrivialString(exec, String(buffer, length));
</del><ins>+    return jsNontrivialString(exec, string.get());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #elif USE(ICU_UNICODE) &amp;&amp; !UCONFIG_NO_FORMATTING
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeIdentifierh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/Identifier.h (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/Identifier.h        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/JavaScriptCore/runtime/Identifier.h        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -55,7 +55,6 @@
</span><span class="cx">         const String&amp; string() const { return m_string; }
</span><span class="cx">         StringImpl* impl() const { return m_string.impl(); }
</span><span class="cx">         
</span><del>-        const UChar* characters() const { return m_string.characters(); }
</del><span class="cx">         int length() const { return m_string.length(); }
</span><span class="cx">         
</span><span class="cx">         CString ascii() const { return m_string.ascii(); }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSStringBuilderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSStringBuilder.h (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSStringBuilder.h        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/JavaScriptCore/runtime/JSStringBuilder.h        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -105,7 +105,7 @@
</span><span class="cx">             }
</span><span class="cx">             upConvert();
</span><span class="cx">         }
</span><del>-        m_okay &amp;= buffer16.tryAppend(str.characters(), length);
</del><ins>+        m_okay &amp;= buffer16.tryAppend(str.characters16(), length);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     void upConvert()
</span></span></pre></div>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/WTF/ChangeLog        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2014-01-12  Darin Adler  &lt;darin@apple.com&gt;
+
+        Reduce use of String::characters
+        https://bugs.webkit.org/show_bug.cgi?id=126854
+
+        Reviewed by Sam Weinig.
+
+        * wtf/text/StringImpl.cpp:
+        (WTF::StringImpl::replace): Use characters16 here since is8Bit was already checked.
+        * wtf/text/WTFString.h:
+        (WTF::String::isAllSpecialCharacters): Use characters16 here since is8Bit was
+        already checked. Also renamed &quot;len&quot; to &quot;length&quot;.
+
</ins><span class="cx"> 2014-01-12  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Replace more uses of AtomicallyInitializedStatic with std::call_once
</span></span></pre></div>
<a id="trunkSourceWTFwtftextStringImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/StringImpl.cpp        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -1489,7 +1489,7 @@
</span><span class="cx">         for (unsigned i = 0; i &lt; length() - position - lengthToReplace; ++i)
</span><span class="cx">             data[i + position + lengthToInsert] = m_data8[i + position + lengthToReplace];
</span><span class="cx">     } else {
</span><del>-        memcpy(data + position + lengthToInsert, characters() + position + lengthToReplace,
</del><ins>+        memcpy(data + position + lengthToInsert, characters16() + position + lengthToReplace,
</ins><span class="cx">             (length() - position - lengthToReplace) * sizeof(UChar));
</span><span class="cx">     }
</span><span class="cx">     return newImpl;
</span></span></pre></div>
<a id="trunkSourceWTFwtftextWTFStringh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/text/WTFString.h (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/text/WTFString.h        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/WTF/wtf/text/WTFString.h        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -624,14 +624,14 @@
</span><span class="cx"> template&lt;bool isSpecialCharacter(UChar)&gt;
</span><span class="cx"> inline bool String::isAllSpecialCharacters() const
</span><span class="cx"> {
</span><del>-    size_t len = length();
</del><ins>+    size_t length = this-&gt;length();
</ins><span class="cx"> 
</span><del>-    if (!len)
</del><ins>+    if (!length)
</ins><span class="cx">         return true;
</span><span class="cx"> 
</span><span class="cx">     if (is8Bit())
</span><del>-        return WTF::isAllSpecialCharacters&lt;isSpecialCharacter, LChar&gt;(characters8(), len);
-    return WTF::isAllSpecialCharacters&lt;isSpecialCharacter, UChar&gt;(characters(), len);
</del><ins>+        return WTF::isAllSpecialCharacters&lt;isSpecialCharacter&gt;(characters8(), length);
+    return WTF::isAllSpecialCharacters&lt;isSpecialCharacter&gt;(characters16(), length);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // StringHash is the default hash for String
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/WebCore/ChangeLog        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -1,3 +1,89 @@
</span><ins>+2014-01-12  Darin Adler  &lt;darin@apple.com&gt;
+
+        Reduce use of String::characters
+        https://bugs.webkit.org/show_bug.cgi?id=126854
+
+        Reviewed by Sam Weinig.
+
+        * bindings/objc/WebScriptObject.mm:
+        (+[WebScriptObject _convertValueToObjcValue:JSC::originRootObject:rootObject:]):
+        Get rid of unneeded code to turn a WTF::String into an NSString, since that's
+        built into the WTF::String class.
+
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::containsOnlyWhitespace): Use WTF::String's [] operator instead of
+        an explicit call to the characters function. Small performance cost.
+        * editing/TypingCommand.cpp:
+        (WebCore::TypingCommand::insertText): Ditto.
+
+        * editing/VisibleUnits.cpp:
+        (WebCore::startOfParagraph): Use reverseFind instead of writing our own loop.
+        (WebCore::endOfParagraph): Use find instead of writing our own loop.
+
+        * html/parser/HTMLParserIdioms.cpp:
+        (WebCore::stripLeadingAndTrailingHTMLSpaces): Use characters16 instead of
+        characters since we have already checked is8Bit.
+        (WebCore::parseHTMLNonNegativeInteger): Ditto. Replace the length check with
+        a check of isNull since a zero length string could be 8 bit, but it's not
+        safe to call is8Bit on a null WTF::String. (That should probably be fixed.)
+
+        * inspector/ContentSearchUtils.cpp:
+        (WebCore::ContentSearchUtils::createSearchRegexSource): Use StringBuilder
+        instead of String in code that builds up a string one character at a time.
+        The old way was ridiculously slow because it allocated a new string for every
+        character; the new way still isn't all that efficient, but it's better. Also
+        changed to use strchr instead of WTF::String::find for special characters.
+
+        * inspector/InspectorStyleSheet.cpp:
+        (WebCore::InspectorStyle::newLineAndWhitespaceDelimiters): Use WTF::String's
+        [] operator instead of an explicit call to the characters function.
+        * inspector/InspectorStyleTextEditor.cpp:
+        (WebCore::InspectorStyleTextEditor::insertProperty): Ditto.
+        (WebCore::InspectorStyleTextEditor::internalReplaceProperty): Ditto.
+        * platform/Length.cpp:
+        (WebCore::newCoordsArray): Ditto.
+
+        * platform/LinkHash.cpp:
+        (WebCore::visitedLinkHash): Use characters16 instead of characters since
+        we have already checked is8Bit. Replace the length check with a check of
+        isNull (as above in parseHTMLNonNegativeInteger).
+
+        * platform/graphics/Color.cpp:
+        (WebCore::Color::parseHexColor): Use characters16 since we already checked is8Bit.
+        (WebCore::Color::Color): Ditto.
+
+        * platform/graphics/TextRun.h:
+        (WebCore::TextRun::TextRun): Use characters16 instead of characters since
+        we have already checked is8Bit. Replace the length check with a check of
+        isNull (as above in parseHTMLNonNegativeInteger).
+
+        * platform/text/TextEncodingRegistry.cpp:
+        (WebCore::atomicCanonicalTextEncodingName): Use characters16 instead of
+        characters since we already checked is8Bit. Also use isEmpty instead of !length.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::constructTextRun): Use characters16 instead of characters
+        since we have already checked is8Bit. Replace the length check with a check of
+        isNull (as above in parseHTMLNonNegativeInteger).
+
+        * rendering/RenderCombineText.cpp:
+        (WebCore::RenderCombineText::width): Check for zero length instead of checking
+        for null characters.
+
+        * svg/SVGFontElement.cpp:
+        (WebCore::SVGFontElement::registerLigaturesInGlyphCache): Rewrite ligatures
+        for loop and give local variables a better name. Construct the substring with
+        the substring function. Still a really inefficient approach -- allocating a new
+        string for every character is absurdly expensive.
+
+        * xml/XPathFunctions.cpp:
+        (WebCore::XPath::FunId::evaluate): Use String instead of StringBuilder. Still
+        not all that efficient, but better than before. Use substring to construct the
+        substring.
+
+        * xml/XPathNodeSet.h: Added begin and end functions so we can use a C++11 for
+        loop with this class.
+
</ins><span class="cx"> 2014-01-12  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Use the Selector Code Generator for matching in SelectorQuery
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsobjcWebScriptObjectmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/objc/WebScriptObject.mm (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/objc/WebScriptObject.mm        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/WebCore/bindings/objc/WebScriptObject.mm        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -548,11 +548,8 @@
</span><span class="cx">         return [WebScriptObject scriptObjectForJSObject:toRef(object) originRootObject:originRootObject rootObject:rootObject];
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (value.isString()) {
-        ExecState* exec = rootObject-&gt;globalObject()-&gt;globalExec();
-        const String&amp; u = asString(value)-&gt;value(exec);
-        return [NSString stringWithCharacters:u.characters() length:u.length()];
-    }
</del><ins>+    if (value.isString())
+        return asString(value)-&gt;value(rootObject-&gt;globalObject()-&gt;globalExec());
</ins><span class="cx"> 
</span><span class="cx">     if (value.isNumber())
</span><span class="cx">         return [NSNumber numberWithDouble:value.asNumber()];
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingCompositeEditCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/CompositeEditCommand.cpp (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/CompositeEditCommand.cpp        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/WebCore/editing/CompositeEditCommand.cpp        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -667,10 +667,9 @@
</span><span class="cx"> static inline bool containsOnlyWhitespace(const String&amp; text)
</span><span class="cx"> {
</span><span class="cx">     for (unsigned i = 0; i &lt; text.length(); ++i) {
</span><del>-        if (!isWhitespace(text.characters()[i]))
</del><ins>+        if (!isWhitespace(text[i]))
</ins><span class="cx">             return false;
</span><span class="cx">     }
</span><del>-    
</del><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingTypingCommandcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/TypingCommand.cpp (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/TypingCommand.cpp        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/WebCore/editing/TypingCommand.cpp        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -152,7 +152,7 @@
</span><span class="cx">     ASSERT(frame);
</span><span class="cx"> 
</span><span class="cx">     if (!text.isEmpty())
</span><del>-        frame-&gt;editor().updateMarkersForWordsAffectedByEditing(isSpaceOrNewline(text.characters()[0]));
</del><ins>+        frame-&gt;editor().updateMarkersForWordsAffectedByEditing(isSpaceOrNewline(text[0]));
</ins><span class="cx">     
</span><span class="cx">     insertText(document, text, frame-&gt;selection().selection(), options, composition);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingVisibleUnitscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/VisibleUnits.cpp (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/VisibleUnits.cpp        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/WebCore/editing/VisibleUnits.cpp        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -1146,15 +1146,10 @@
</span><span class="cx">             ASSERT_WITH_SECURITY_IMPLICATION(n-&gt;isTextNode());
</span><span class="cx">             type = Position::PositionIsOffsetInAnchor;
</span><span class="cx">             if (style.preserveNewline()) {
</span><del>-                const UChar* chars = toRenderText(r)-&gt;characters();
-                int i = toRenderText(r)-&gt;textLength();
-                int o = offset;
-                if (n == startNode &amp;&amp; o &lt; i)
-                    i = std::max(0, o);
-                while (--i &gt;= 0) {
-                    if (chars[i] == '\n')
-                        return VisiblePosition(Position(toText(n), i + 1), DOWNSTREAM);
-                }
</del><ins>+                unsigned startOffset = n == startNode ? std::max(0, offset) : std::numeric_limits&lt;unsigned&gt;::max();
+                size_t newlineOffset = toRenderText(r)-&gt;text()-&gt;reverseFind('\n', startOffset);
+                if (newlineOffset != notFound)
+                    return VisiblePosition(Position(toText(n), newlineOffset + 1), DOWNSTREAM);
</ins><span class="cx">             }
</span><span class="cx">             node = n;
</span><span class="cx">             offset = 0;
</span><span class="lines">@@ -1226,15 +1221,11 @@
</span><span class="cx">         // FIXME: We avoid returning a position where the renderer can't accept the caret.
</span><span class="cx">         if (r-&gt;isText() &amp;&amp; toRenderText(r)-&gt;hasRenderedText()) {
</span><span class="cx">             ASSERT_WITH_SECURITY_IMPLICATION(n-&gt;isTextNode());
</span><del>-            int length = toRenderText(r)-&gt;textLength();
</del><span class="cx">             type = Position::PositionIsOffsetInAnchor;
</span><span class="cx">             if (style.preserveNewline()) {
</span><del>-                const UChar* chars = toRenderText(r)-&gt;characters();
-                int o = n == startNode ? offset : 0;
-                for (int i = o; i &lt; length; ++i) {
-                    if (chars[i] == '\n')
-                        return VisiblePosition(Position(toText(n), i), DOWNSTREAM);
-                }
</del><ins>+                size_t newlineOffset = toRenderText(r)-&gt;text()-&gt;find('\n', n == startNode ? offset : 0);
+                if (newlineOffset != notFound)
+                    return VisiblePosition(Position(toText(n), newlineOffset), DOWNSTREAM);
</ins><span class="cx">             }
</span><span class="cx">             node = n;
</span><span class="cx">             offset = r-&gt;caretMaxOffset();
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserHTMLParserIdiomscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -71,7 +71,7 @@
</span><span class="cx">     if (string.is8Bit())
</span><span class="cx">         return stripLeadingAndTrailingHTMLSpaces(string, string.characters8(), length);
</span><span class="cx"> 
</span><del>-    return stripLeadingAndTrailingHTMLSpaces(string, string.characters(), length);
</del><ins>+    return stripLeadingAndTrailingHTMLSpaces(string, string.characters16(), length);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> String serializeForNumberType(const Decimal&amp; number)
</span><span class="lines">@@ -267,12 +267,12 @@
</span><span class="cx">     // Step 1
</span><span class="cx">     // Step 2
</span><span class="cx">     unsigned length = input.length();
</span><del>-    if (length &amp;&amp; input.is8Bit()) {
</del><ins>+    if (input.isNull() || input.is8Bit()) {
</ins><span class="cx">         const LChar* start = input.characters8();
</span><span class="cx">         return parseHTMLNonNegativeIntegerInternal(start, start + length, value);
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    const UChar* start = input.characters();
</del><ins>+    const UChar* start = input.characters16();
</ins><span class="cx">     return parseHTMLNonNegativeIntegerInternal(start, start + length, value);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorContentSearchUtilscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/ContentSearchUtils.cpp (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/ContentSearchUtils.cpp        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/WebCore/inspector/ContentSearchUtils.cpp        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #include &lt;inspector/InspectorValues.h&gt;
</span><span class="cx"> #include &lt;wtf/BumpPointerAllocator.h&gt;
</span><span class="cx"> #include &lt;wtf/StdLibExtras.h&gt;
</span><ins>+#include &lt;wtf/text/StringBuilder.h&gt;
</ins><span class="cx"> #include &lt;yarr/Yarr.h&gt;
</span><span class="cx"> 
</span><span class="cx"> using namespace Inspector;
</span><span class="lines">@@ -50,17 +51,13 @@
</span><span class="cx"> 
</span><span class="cx"> static String createSearchRegexSource(const String&amp; text)
</span><span class="cx"> {
</span><del>-    String result;
-    const UChar* characters = text.characters();
-    String specials(regexSpecialCharacters);
-
</del><ins>+    StringBuilder result;
</ins><span class="cx">     for (unsigned i = 0; i &lt; text.length(); i++) {
</span><del>-        if (specials.find(characters[i]) != notFound)
-            result.append(&quot;\\&quot;);
-        result.append(characters[i]);
</del><ins>+        if (isASCII(text[i]) &amp;&amp; strchr(regexSpecialCharacters, text[i]))
+            result.append('\\');
+        result.append(text[i]);
</ins><span class="cx">     }
</span><del>-
-    return result;
</del><ins>+    return result.toString();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static inline size_t sizetExtractor(const size_t* value)
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorStyleSheetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -723,14 +723,13 @@
</span><span class="cx">     int propertyIndex = 0;
</span><span class="cx">     bool isFullPrefixScanned = false;
</span><span class="cx">     bool lineFeedTerminated = false;
</span><del>-    const UChar* characters = text.characters();
</del><span class="cx">     while (propertyIndex &lt; propertyCount) {
</span><span class="cx">         const WebCore::CSSPropertySourceData&amp; currentProperty = sourcePropertyData-&gt;at(propertyIndex++);
</span><span class="cx"> 
</span><span class="cx">         bool processNextProperty = false;
</span><span class="cx">         int scanEnd = currentProperty.range.start;
</span><span class="cx">         for (int i = scanStart; i &lt; scanEnd; ++i) {
</span><del>-            UChar ch = characters[i];
</del><ins>+            UChar ch = text[i];
</ins><span class="cx">             bool isLineFeed = isHTMLLineBreak(ch);
</span><span class="cx">             if (isLineFeed) {
</span><span class="cx">                 if (!lineFeedTerminated)
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorStyleTextEditorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorStyleTextEditor.cpp (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorStyleTextEditor.cpp        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/WebCore/inspector/InspectorStyleTextEditor.cpp        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -82,12 +82,10 @@
</span><span class="cx">     if (insertLast &amp;&amp; !insertFirstInSource) {
</span><span class="cx">         propertyStart = styleBodyLength;
</span><span class="cx">         if (propertyStart &amp;&amp; textToSet.length()) {
</span><del>-            const UChar* characters = m_styleText.characters();
-
</del><span class="cx">             long curPos = propertyStart - 1; // The last position of style declaration, since propertyStart points past one.
</span><del>-            while (curPos &amp;&amp; isHTMLSpace(characters[curPos]))
</del><ins>+            while (curPos &amp;&amp; isHTMLSpace(m_styleText[curPos]))
</ins><span class="cx">                 --curPos;
</span><del>-            if (curPos &amp;&amp; characters[curPos] != ';') {
</del><ins>+            if (curPos &amp;&amp; m_styleText[curPos] != ';') {
</ins><span class="cx">                 // Prepend a &quot;;&quot; to the property text if appending to a style declaration where
</span><span class="cx">                 // the last property has no trailing &quot;;&quot;.
</span><span class="cx">                 textToSet.insert(&quot;;&quot;, 0);
</span><span class="lines">@@ -230,7 +228,6 @@
</span><span class="cx">     const SourceRange&amp; range = property.sourceData.range;
</span><span class="cx">     long replaceRangeStart = range.start;
</span><span class="cx">     long replaceRangeEnd = range.end;
</span><del>-    const UChar* characters = m_styleText.characters();
</del><span class="cx">     long newTextLength = newText.length();
</span><span class="cx">     String finalNewText = newText;
</span><span class="cx"> 
</span><span class="lines">@@ -241,14 +238,14 @@
</span><span class="cx">         if (replaceRangeStart &gt;= fullPrefixLength &amp;&amp; m_styleText.substring(replaceRangeStart - fullPrefixLength, fullPrefixLength) == fullPrefix)
</span><span class="cx">             replaceRangeStart -= fullPrefixLength;
</span><span class="cx">     } else if (newTextLength) {
</span><del>-        if (isHTMLLineBreak(newText.characters()[newTextLength - 1])) {
</del><ins>+        if (isHTMLLineBreak(newText[newTextLength - 1])) {
</ins><span class="cx">             // Coalesce newlines of the original and new property values (to avoid a lot of blank lines while incrementally applying property values).
</span><span class="cx">             bool foundNewline = false;
</span><span class="cx">             bool isLastNewline = false;
</span><span class="cx">             int i;
</span><span class="cx">             int textLength = m_styleText.length();
</span><del>-            for (i = replaceRangeEnd; i &lt; textLength &amp;&amp; isSpaceOrNewline(characters[i]); ++i) {
-                isLastNewline = isHTMLLineBreak(characters[i]);
</del><ins>+            for (i = replaceRangeEnd; i &lt; textLength &amp;&amp; isSpaceOrNewline(m_styleText[i]); ++i) {
+                isLastNewline = isHTMLLineBreak(m_styleText[i]);
</ins><span class="cx">                 if (isLastNewline)
</span><span class="cx">                     foundNewline = true;
</span><span class="cx">                 else if (foundNewline &amp;&amp; !isLastNewline) {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformLengthcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/Length.cpp (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/Length.cpp        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/WebCore/platform/Length.cpp        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -88,10 +88,9 @@
</span><span class="cx"> std::unique_ptr&lt;Length[]&gt; newCoordsArray(const String&amp; string, int&amp; len)
</span><span class="cx"> {
</span><span class="cx">     unsigned length = string.length();
</span><del>-    const UChar* data = string.characters();
</del><span class="cx">     StringBuffer&lt;UChar&gt; spacified(length);
</span><span class="cx">     for (unsigned i = 0; i &lt; length; i++) {
</span><del>-        UChar cc = data[i];
</del><ins>+        UChar cc = string[i];
</ins><span class="cx">         if (cc &gt; '9' || (cc &lt; '0' &amp;&amp; cc != '-' &amp;&amp; cc != '*' &amp;&amp; cc != '.'))
</span><span class="cx">             spacified[i] = ' ';
</span><span class="cx">         else
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformLinkHashcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/LinkHash.cpp (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/LinkHash.cpp        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/WebCore/platform/LinkHash.cpp        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -214,10 +214,9 @@
</span><span class="cx"> LinkHash visitedLinkHash(const String&amp; url)
</span><span class="cx"> {
</span><span class="cx">     unsigned length = url.length();
</span><del>-
-    if (length &amp;&amp; url.is8Bit())
</del><ins>+    if (url.isNull() || url.is8Bit())
</ins><span class="cx">         return visitedLinkHashInline(url.characters8(), length);
</span><del>-    return visitedLinkHashInline(url.characters(), length);
</del><ins>+    return visitedLinkHashInline(url.characters16(), length);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> LinkHash visitedLinkHash(const UChar* url, unsigned length)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsColorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/Color.cpp (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/Color.cpp        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/WebCore/platform/graphics/Color.cpp        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -165,7 +165,7 @@
</span><span class="cx">         return false;
</span><span class="cx">     if (name.is8Bit())
</span><span class="cx">         return parseHexColor(name.characters8(), name.length(), rgb);
</span><del>-    return parseHexColor(name.characters(), name.length(), rgb);
</del><ins>+    return parseHexColor(name.characters16(), name.length(), rgb);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int differenceSquared(const Color&amp; c1, const Color&amp; c2)
</span><span class="lines">@@ -182,7 +182,7 @@
</span><span class="cx">         if (name.is8Bit())
</span><span class="cx">             m_valid = parseHexColor(name.characters8() + 1, name.length() - 1, m_color);
</span><span class="cx">         else
</span><del>-            m_valid = parseHexColor(name.characters() + 1, name.length() - 1, m_color);
</del><ins>+            m_valid = parseHexColor(name.characters16() + 1, name.length() - 1, m_color);
</ins><span class="cx">     } else
</span><span class="cx">         setNamedColor(name);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsTextRunh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/TextRun.h (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/TextRun.h        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/WebCore/platform/graphics/TextRun.h        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -124,11 +124,11 @@
</span><span class="cx">         , m_tabSize(0)
</span><span class="cx">     {
</span><span class="cx"> #if ENABLE(8BIT_TEXTRUN)
</span><del>-        if (m_charactersLength &amp;&amp; s.is8Bit()) {
</del><ins>+        if (s.isNull() || s.is8Bit()) {
</ins><span class="cx">             m_data.characters8 = s.characters8();
</span><span class="cx">             m_is8Bit = true;
</span><span class="cx">         } else {
</span><del>-            m_data.characters16 = s.characters();
</del><ins>+            m_data.characters16 = s.characters16();
</ins><span class="cx">             m_is8Bit = false;
</span><span class="cx">         }
</span><span class="cx"> #else
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformtextTextEncodingRegistrycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/text/TextEncodingRegistry.cpp (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/text/TextEncodingRegistry.cpp        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/WebCore/platform/text/TextEncodingRegistry.cpp        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -343,13 +343,13 @@
</span><span class="cx"> 
</span><span class="cx"> const char* atomicCanonicalTextEncodingName(const String&amp; alias)
</span><span class="cx"> {
</span><del>-    if (!alias.length())
-        return 0;
</del><ins>+    if (alias.isEmpty())
+        return nullptr;
</ins><span class="cx"> 
</span><span class="cx">     if (alias.is8Bit())
</span><span class="cx">         return atomicCanonicalTextEncodingName&lt;LChar&gt;(alias.characters8(), alias.length());
</span><span class="cx"> 
</span><del>-    return atomicCanonicalTextEncodingName&lt;UChar&gt;(alias.characters(), alias.length());
</del><ins>+    return atomicCanonicalTextEncodingName&lt;UChar&gt;(alias.characters16(), alias.length());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool noExtendedTextEncodingNameUsed()
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlock.cpp        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -5479,11 +5479,10 @@
</span><span class="cx"> TextRun RenderBlock::constructTextRun(RenderObject* context, const Font&amp; font, const String&amp; string, const RenderStyle&amp; style, TextRun::ExpansionBehavior expansion, TextRunFlags flags)
</span><span class="cx"> {
</span><span class="cx">     unsigned length = string.length();
</span><del>-
</del><span class="cx"> #if ENABLE(8BIT_TEXTRUN)
</span><del>-    if (length &amp;&amp; string.is8Bit())
</del><ins>+    if (string.isNull() || string.is8Bit())
</ins><span class="cx">         return constructTextRunInternal(context, font, string.characters8(), length, style, expansion, flags);
</span><del>-    return constructTextRunInternal(context, font, string.characters(), length, style, expansion, flags);
</del><ins>+    return constructTextRunInternal(context, font, string.characters16(), length, style, expansion, flags);
</ins><span class="cx"> #else
</span><span class="cx">     return constructTextRunInternal(context, font, string.characters(), length, style, expansion, flags);
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderCombineTextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderCombineText.cpp (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderCombineText.cpp        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/WebCore/rendering/RenderCombineText.cpp        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -60,7 +60,7 @@
</span><span class="cx"> 
</span><span class="cx"> float RenderCombineText::width(unsigned from, unsigned length, const Font&amp; font, float xPosition, HashSet&lt;const SimpleFontData*&gt;* fallbackFonts, GlyphOverflow* glyphOverflow) const
</span><span class="cx"> {
</span><del>-    if (!characters())
</del><ins>+    if (!textLength())
</ins><span class="cx">         return 0;
</span><span class="cx"> 
</span><span class="cx">     if (m_isCombined)
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGFontElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGFontElement.cpp (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGFontElement.cpp        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/WebCore/svg/SVGFontElement.cpp        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -87,16 +87,13 @@
</span><span class="cx">     // will not be able to find a glyph for &quot;f&quot;, but handles the fallback
</span><span class="cx">     // character substitution properly through glyphDataForCharacter().
</span><span class="cx">     Vector&lt;SVGGlyph&gt; glyphs;
</span><del>-    size_t ligaturesSize = ligatures.size();
-    for (size_t i = 0; i &lt; ligaturesSize; ++i) {
-        const String&amp; unicode = ligatures[i];
</del><ins>+    for (auto&amp; ligature : ligatures) {
+        unsigned ligatureLength = ligature.length();
+        ASSERT(ligatureLength &gt; 1);
</ins><span class="cx"> 
</span><del>-        unsigned unicodeLength = unicode.length();
-        ASSERT(unicodeLength &gt; 1);
-
-        const UChar* characters = unicode.characters();
-        for (unsigned i = 0; i &lt; unicodeLength; ++i) {
-            String lookupString(characters + i, 1);
</del><ins>+        for (unsigned i = 0; i &lt; ligatureLength; ++i) {
+            // FIXME: Is there a faster way to do this without allocating/deallocating a string for every character in every ligature?
+            String lookupString(ligature.substring(i, 1));
</ins><span class="cx">             m_glyphMap.collectGlyphsForString(lookupString, glyphs);
</span><span class="cx">             if (!glyphs.isEmpty()) {
</span><span class="cx">                 glyphs.clear();
</span></span></pre></div>
<a id="trunkSourceWebCorexmlXPathFunctionscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/XPathFunctions.cpp (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/XPathFunctions.cpp        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/WebCore/xml/XPathFunctions.cpp        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -307,18 +307,17 @@
</span><span class="cx"> Value FunId::evaluate() const
</span><span class="cx"> {
</span><span class="cx">     Value a = argument(0).evaluate();
</span><del>-    StringBuilder idList; // A whitespace-separated list of IDs
</del><span class="cx"> 
</span><ins>+    String idList; // A whitespace-separated list of IDs
</ins><span class="cx">     if (a.isNodeSet()) {
</span><del>-        const NodeSet&amp; nodes = a.toNodeSet();
-        for (size_t i = 0; i &lt; nodes.size(); ++i) {
-            String str = stringValue(nodes[i]);
-            idList.append(str);
-            idList.append(' ');
</del><ins>+        StringBuilder spaceSeparatedList;
+        for (auto&amp; node : a.toNodeSet()) {
+            spaceSeparatedList.append(stringValue(node.get()));
+            spaceSeparatedList.append(' ');
</ins><span class="cx">         }
</span><ins>+        idList = spaceSeparatedList.toString();
</ins><span class="cx">     } else {
</span><del>-        String str = a.toString();
-        idList.append(str);
</del><ins>+        idList = a.toString();
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     TreeScope&amp; contextScope = evaluationContext().node-&gt;treeScope();
</span><span class="lines">@@ -340,7 +339,7 @@
</span><span class="cx"> 
</span><span class="cx">         // If there are several nodes with the same id, id() should return the first one.
</span><span class="cx">         // In WebKit, getElementById behaves so, too, although its behavior in this case is formally undefined.
</span><del>-        Node* node = contextScope.getElementById(String(idList.characters() + startPos, endPos - startPos));
</del><ins>+        Node* node = contextScope.getElementById(idList.substring(startPos, endPos - startPos));
</ins><span class="cx">         if (node &amp;&amp; resultSet.add(node).isNewEntry)
</span><span class="cx">             result.append(node);
</span><span class="cx">         
</span></span></pre></div>
<a id="trunkSourceWebCorexmlXPathNodeSeth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/XPathNodeSet.h (161839 => 161840)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/XPathNodeSet.h        2014-01-12 23:04:19 UTC (rev 161839)
+++ trunk/Source/WebCore/xml/XPathNodeSet.h        2014-01-12 23:23:44 UTC (rev 161840)
</span><span class="lines">@@ -44,6 +44,9 @@
</span><span class="cx">             void reserveCapacity(size_t newCapacity) { m_nodes.reserveCapacity(newCapacity); }
</span><span class="cx">             void clear() { m_nodes.clear(); }
</span><span class="cx"> 
</span><ins>+            Vector&lt;RefPtr&lt;Node&gt;&gt;::const_iterator begin() const { return m_nodes.begin(); }
+            Vector&lt;RefPtr&lt;Node&gt;&gt;::const_iterator end() const { return m_nodes.end(); }
+
</ins><span class="cx">             // NodeSet itself does not verify that nodes in it are unique.
</span><span class="cx">             void append(PassRefPtr&lt;Node&gt; node) { m_nodes.append(node); }
</span><span class="cx">             void append(const NodeSet&amp; nodeSet) { m_nodes.appendVector(nodeSet.m_nodes); }
</span></span></pre>
</div>
</div>

</body>
</html>