Title: [166047] trunk/Source
Revision
166047
Author
[email protected]
Date
2014-03-21 00:13:59 -0700 (Fri, 21 Mar 2014)

Log Message

Improve idiom used for string building in a few places
https://bugs.webkit.org/show_bug.cgi?id=130561

Reviewed by Andreas Kling.

Source/WebCore:

* Modules/indexeddb/IDBKeyData.cpp:
(WebCore::IDBKeyData::loggingString): Use a StringBuilder, and get rid of
an an unnecessary additional string allocation.

* Modules/websockets/ThreadableWebSocketChannel.cpp:
(WebCore::ThreadableWebSocketChannel::create): Use StringBuilder.

* html/FTPDirectoryDocument.cpp:
(WebCore::FTPDirectoryDocumentParser::createTDForFilename): Do a more efficient
string concatenation.
* html/ValidationMessage.cpp:
(WebCore::ValidationMessage::updateValidationMessage): Ditto.

* inspector/InspectorApplicationCacheAgent.cpp:
(WebCore::InspectorApplicationCacheAgent::buildObjectForApplicationCacheResource):
Use a StringBuilder.

* inspector/InspectorStyleSheet.cpp:
(WebCore::InspectorStyle::shorthandValue): Use a StringBuilder.

* inspector/InspectorStyleTextEditor.cpp:
(WebCore::InspectorStyleTextEditor::insertProperty): Use a more efficient idiom
for string concatenation.
(WebCore::InspectorStyleTextEditor::internalReplaceProperty): Ditto.
* loader/FormSubmission.cpp:
(WebCore::appendMailtoPostFormDataToURL): Ditto.

* page/Frame.cpp:
(WebCore::createRegExpForLabels): Use a StringBuilder.

* platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
(WebCore::InbandTextTrackPrivateAVF::processCueAttributes): Use a more efficient
idiom for string concatenation.

* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::getUnmangledInfoLog): Use a StringBuilder.

* platform/network/MIMEHeader.cpp:
(WebCore::MIMEHeader::parseHeader): Use a more efficient idiom for string
concatenation.
* platform/network/ResourceResponseBase.cpp:
(WebCore::ResourceResponseBase::addHTTPHeaderField): Ditto.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::layerTreeAsText): Ditto.

* rendering/RenderText.cpp:
(WebCore::RenderText::secureText): Create a new string with the substring
function rather than with the append function.

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::setRequestHeaderInternal): Use a more efficient idiom
for string concatenation.

Source/WebKit/mac:

* WebView/WebHTMLRepresentation.mm:
(regExpForLabels): Use StringBuilder.

Source/WebKit2:

* Shared/mac/ChildProcessMac.mm:
(WebKit::ChildProcess::initializeSandbox): Use a more efficient idiom for string
concatenation.

* UIProcess/WebInspectorProxy.cpp:
(WebKit::WebInspectorProxy::createInspectorPage): Use a StringBuilder.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (166046 => 166047)


--- trunk/Source/WebCore/ChangeLog	2014-03-21 07:12:07 UTC (rev 166046)
+++ trunk/Source/WebCore/ChangeLog	2014-03-21 07:13:59 UTC (rev 166047)
@@ -1,5 +1,65 @@
 2014-03-21  Darin Adler  <[email protected]>
 
+        Improve idiom used for string building in a few places
+        https://bugs.webkit.org/show_bug.cgi?id=130561
+
+        Reviewed by Andreas Kling.
+
+        * Modules/indexeddb/IDBKeyData.cpp:
+        (WebCore::IDBKeyData::loggingString): Use a StringBuilder, and get rid of
+        an an unnecessary additional string allocation.
+
+        * Modules/websockets/ThreadableWebSocketChannel.cpp:
+        (WebCore::ThreadableWebSocketChannel::create): Use StringBuilder.
+
+        * html/FTPDirectoryDocument.cpp:
+        (WebCore::FTPDirectoryDocumentParser::createTDForFilename): Do a more efficient
+        string concatenation.
+        * html/ValidationMessage.cpp:
+        (WebCore::ValidationMessage::updateValidationMessage): Ditto.
+
+        * inspector/InspectorApplicationCacheAgent.cpp:
+        (WebCore::InspectorApplicationCacheAgent::buildObjectForApplicationCacheResource):
+        Use a StringBuilder.
+
+        * inspector/InspectorStyleSheet.cpp: 
+        (WebCore::InspectorStyle::shorthandValue): Use a StringBuilder.
+
+        * inspector/InspectorStyleTextEditor.cpp:
+        (WebCore::InspectorStyleTextEditor::insertProperty): Use a more efficient idiom
+        for string concatenation.
+        (WebCore::InspectorStyleTextEditor::internalReplaceProperty): Ditto.
+        * loader/FormSubmission.cpp:
+        (WebCore::appendMailtoPostFormDataToURL): Ditto.
+
+        * page/Frame.cpp:
+        (WebCore::createRegExpForLabels): Use a StringBuilder.
+
+        * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
+        (WebCore::InbandTextTrackPrivateAVF::processCueAttributes): Use a more efficient
+        idiom for string concatenation.
+
+        * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
+        (WebCore::GraphicsContext3D::getUnmangledInfoLog): Use a StringBuilder.
+
+        * platform/network/MIMEHeader.cpp:
+        (WebCore::MIMEHeader::parseHeader): Use a more efficient idiom for string
+        concatenation.
+        * platform/network/ResourceResponseBase.cpp:
+        (WebCore::ResourceResponseBase::addHTTPHeaderField): Ditto.
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::layerTreeAsText): Ditto.
+
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::secureText): Create a new string with the substring
+        function rather than with the append function.
+
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::setRequestHeaderInternal): Use a more efficient idiom
+        for string concatenation.
+
+2014-03-21  Darin Adler  <[email protected]>
+
         Add a combined decodeAndFlush to TextResourceDecoder
         https://bugs.webkit.org/show_bug.cgi?id=130560
 

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp (166046 => 166047)


--- trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp	2014-03-21 07:12:07 UTC (rev 166046)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBKeyData.cpp	2014-03-21 07:13:59 UTC (rev 166047)
@@ -29,6 +29,7 @@
 #if ENABLE(INDEXED_DATABASE)
 
 #include "KeyedCoding.h"
+#include <wtf/text/StringBuilder.h>
 
 namespace WebCore {
 
@@ -260,17 +261,18 @@
         return "<invalid>";
     case IDBKey::ArrayType:
         {
-            String result = "<array> - { ";
+            StringBuilder result;
+            result.appendLiteral("<array> - { ");
             for (size_t i = 0; i < arrayValue.size(); ++i) {
                 result.append(arrayValue[i].loggingString());
                 if (i < arrayValue.size() - 1)
                     result.append(", ");
             }
             result.append(" }");
-            return result;
+            return result.toString();
         }
     case IDBKey::StringType:
-        return String("<string> - ") + stringValue;
+        return "<string> - " + stringValue;
     case IDBKey::DateType:
         return String::format("Date type - %f", numberValue);
     case IDBKey::NumberType:

Modified: trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp (166046 => 166047)


--- trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp	2014-03-21 07:12:07 UTC (rev 166046)
+++ trunk/Source/WebCore/Modules/websockets/ThreadableWebSocketChannel.cpp	2014-03-21 07:13:59 UTC (rev 166047)
@@ -44,7 +44,7 @@
 #include "WorkerThread.h"
 #include "WorkerThreadableWebSocketChannel.h"
 #include <wtf/PassRefPtr.h>
-#include <wtf/text/WTFString.h>
+#include <wtf/text/StringBuilder.h>
 
 namespace WebCore {
 
@@ -58,9 +58,10 @@
     if (context->isWorkerGlobalScope()) {
         WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context);
         WorkerRunLoop& runLoop = workerGlobalScope->thread().runLoop();
-        String mode = webSocketChannelMode;
-        mode.append(String::number(runLoop.createUniqueId()));
-        return WorkerThreadableWebSocketChannel::create(workerGlobalScope, client, mode);
+        StringBuilder mode;
+        mode.appendLiteral(webSocketChannelMode);
+        mode.appendNumber(runLoop.createUniqueId());
+        return WorkerThreadableWebSocketChannel::create(workerGlobalScope, client, mode.toString());
     }
 
     return WebSocketChannel::create(toDocument(context), client);

Modified: trunk/Source/WebCore/html/FTPDirectoryDocument.cpp (166046 => 166047)


--- trunk/Source/WebCore/html/FTPDirectoryDocument.cpp	2014-03-21 07:12:07 UTC (rev 166046)
+++ trunk/Source/WebCore/html/FTPDirectoryDocument.cpp	2014-03-21 07:13:59 UTC (rev 166047)
@@ -136,9 +136,9 @@
 {
     String fullURL = document()->baseURL().string();
     if (fullURL.endsWith('/'))
-        fullURL.append(filename);
+        fullURL = fullURL + filename;
     else
-        fullURL.append(makeString('/', filename));
+        fullURL = fullURL + '/' + filename;
 
     RefPtr<Element> anchorElement = document()->createElement(aTag, false);
     anchorElement->setAttribute(HTMLNames::hrefAttr, fullURL);

Modified: trunk/Source/WebCore/html/ValidationMessage.cpp (166046 => 166047)


--- trunk/Source/WebCore/html/ValidationMessage.cpp	2014-03-21 07:12:07 UTC (rev 166046)
+++ trunk/Source/WebCore/html/ValidationMessage.cpp	2014-03-21 07:13:59 UTC (rev 166047)
@@ -87,10 +87,10 @@
         // HTML5 specification doesn't ask UA to show the title attribute value
         // with the validationMessage. However, this behavior is same as Opera
         // and the specification describes such behavior as an example.
-        const AtomicString& title = m_element->fastGetAttribute(titleAttr);
-        if (!updatedMessage.isEmpty() && !title.isEmpty()) {
-            updatedMessage.append('\n');
-            updatedMessage.append(title);
+        if (!updatedMessage.isEmpty()) {
+            const AtomicString& title = m_element->fastGetAttribute(titleAttr);
+            if (!title.isEmpty())
+                updatedMessage = updatedMessage + '\n' + title;
         }
     }
 

Modified: trunk/Source/WebCore/inspector/InspectorApplicationCacheAgent.cpp (166046 => 166047)


--- trunk/Source/WebCore/inspector/InspectorApplicationCacheAgent.cpp	2014-03-21 07:12:07 UTC (rev 166046)
+++ trunk/Source/WebCore/inspector/InspectorApplicationCacheAgent.cpp	2014-03-21 07:13:59 UTC (rev 166047)
@@ -40,6 +40,7 @@
 #include "Page.h"
 #include "ResourceResponse.h"
 #include <inspector/InspectorValues.h>
+#include <wtf/text/StringBuilder.h>
 
 using namespace Inspector;
 
@@ -173,26 +174,27 @@
 
 PassRefPtr<Inspector::TypeBuilder::ApplicationCache::ApplicationCacheResource> InspectorApplicationCacheAgent::buildObjectForApplicationCacheResource(const ApplicationCacheHost::ResourceInfo& resourceInfo)
 {
-    String types;
+    StringBuilder types;
+
     if (resourceInfo.m_isMaster)
-        types.append("Master ");
+        types.appendLiteral("Master ");
 
     if (resourceInfo.m_isManifest)
-        types.append("Manifest ");
+        types.appendLiteral("Manifest ");
 
     if (resourceInfo.m_isFallback)
-        types.append("Fallback ");
+        types.appendLiteral("Fallback ");
 
     if (resourceInfo.m_isForeign)
-        types.append("Foreign ");
+        types.appendLiteral("Foreign ");
 
     if (resourceInfo.m_isExplicit)
-        types.append("Explicit ");
+        types.appendLiteral("Explicit ");
 
     RefPtr<Inspector::TypeBuilder::ApplicationCache::ApplicationCacheResource> value = Inspector::TypeBuilder::ApplicationCache::ApplicationCacheResource::create()
         .setUrl(resourceInfo.m_resource.string())
         .setSize(static_cast<int>(resourceInfo.m_size))
-        .setType(types);
+        .setType(types.toString());
     return value;
 }
 

Modified: trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp (166046 => 166047)


--- trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp	2014-03-21 07:12:07 UTC (rev 166046)
+++ trunk/Source/WebCore/inspector/InspectorStyleSheet.cpp	2014-03-21 07:13:59 UTC (rev 166047)
@@ -635,22 +635,23 @@
 String InspectorStyle::shorthandValue(const String& shorthandProperty) const
 {
     String value = m_style->getPropertyValue(shorthandProperty);
-    if (value.isEmpty()) {
-        for (unsigned i = 0; i < m_style->length(); ++i) {
-            String individualProperty = m_style->item(i);
-            if (m_style->getPropertyShorthand(individualProperty) != shorthandProperty)
-                continue;
-            if (m_style->isPropertyImplicit(individualProperty))
-                continue;
-            String individualValue = m_style->getPropertyValue(individualProperty);
-            if (individualValue == "initial")
-                continue;
-            if (value.length())
-                value.append(" ");
-            value.append(individualValue);
-        }
+    if (!value.isEmpty())
+        return value;
+    StringBuilder builder;
+    for (unsigned i = 0; i < m_style->length(); ++i) {
+        String individualProperty = m_style->item(i);
+        if (m_style->getPropertyShorthand(individualProperty) != shorthandProperty)
+            continue;
+        if (m_style->isPropertyImplicit(individualProperty))
+            continue;
+        String individualValue = m_style->getPropertyValue(individualProperty);
+        if (individualValue == "initial")
+            continue;
+        if (!builder.isEmpty())
+            builder.append(' ');
+        builder.append(individualValue);
     }
-    return value;
+    return builder.toString();
 }
 
 String InspectorStyle::shorthandPriority(const String& shorthandProperty) const

Modified: trunk/Source/WebCore/inspector/InspectorStyleTextEditor.cpp (166046 => 166047)


--- trunk/Source/WebCore/inspector/InspectorStyleTextEditor.cpp	2014-03-21 07:12:07 UTC (rev 166046)
+++ trunk/Source/WebCore/inspector/InspectorStyleTextEditor.cpp	2014-03-21 07:13:59 UTC (rev 166047)
@@ -88,7 +88,7 @@
             if (curPos && m_styleText[curPos] != ';') {
                 // Prepend a ";" to the property text if appending to a style declaration where
                 // the last property has no trailing ";".
-                textToSet.insert(";", 0);
+                textToSet = makeString(';', textToSet);
                 formattingPrependOffset = 1;
             }
         }
@@ -258,7 +258,7 @@
         }
 
         if (fullPrefixLength > replaceRangeStart || m_styleText.substring(replaceRangeStart - fullPrefixLength, fullPrefixLength) != fullPrefix)
-            finalNewText.insert(fullPrefix, 0);
+            finalNewText = fullPrefix + finalNewText;
     }
 
     int replacedLength = replaceRangeEnd - replaceRangeStart;

Modified: trunk/Source/WebCore/loader/FormSubmission.cpp (166046 => 166047)


--- trunk/Source/WebCore/loader/FormSubmission.cpp	2014-03-21 07:12:07 UTC (rev 166046)
+++ trunk/Source/WebCore/loader/FormSubmission.cpp	2014-03-21 07:13:59 UTC (rev 166047)
@@ -76,10 +76,10 @@
     body = String(bodyData.data(), bodyData.size()).replaceWithLiteral('+', "%20");
 
     String query = url.query();
-    if (!query.isEmpty())
-        query.append('&');
-    query.append(body);
-    url.setQuery(query);
+    if (query.isEmpty())
+        url.setQuery(body);
+    else
+        url.setQuery(query + '&' + body);
 }
 
 void FormSubmission::Attributes::parseAction(const String& action)

Modified: trunk/Source/WebCore/page/Frame.cpp (166046 => 166047)


--- trunk/Source/WebCore/page/Frame.cpp	2014-03-21 07:12:07 UTC (rev 166046)
+++ trunk/Source/WebCore/page/Frame.cpp	2014-03-21 07:13:59 UTC (rev 166047)
@@ -318,7 +318,8 @@
     // the same across calls.  We can't do that.
 
     DEPRECATED_DEFINE_STATIC_LOCAL(JSC::Yarr::RegularExpression, wordRegExp, ("\\w", TextCaseSensitive));
-    String pattern("(");
+    StringBuilder pattern;
+    pattern.append('(');
     unsigned int numLabels = labels.size();
     unsigned int i;
     for (i = 0; i < numLabels; i++) {
@@ -332,18 +333,18 @@
         }
 
         if (i)
-            pattern.append("|");
+            pattern.append('|');
         // Search for word boundaries only if label starts/ends with "word characters".
         // If we always searched for word boundaries, this wouldn't work for languages
         // such as Japanese.
         if (startsWithWordChar)
-            pattern.append("\\b");
+            pattern.appendLiteral("\\b");
         pattern.append(label);
         if (endsWithWordChar)
-            pattern.append("\\b");
+            pattern.appendLiteral("\\b");
     }
-    pattern.append(")");
-    return adoptPtr(new JSC::Yarr::RegularExpression(pattern, TextCaseInsensitive));
+    pattern.append(')');
+    return adoptPtr(new JSC::Yarr::RegularExpression(pattern.toString(), TextCaseInsensitive));
 }
 
 String Frame::searchForLabelsAboveCell(JSC::Yarr::RegularExpression* regExp, HTMLTableCellElement* cell, size_t* resultDistanceFromStartOfCell)

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp (166046 => 166047)


--- trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp	2014-03-21 07:12:07 UTC (rev 166046)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp	2014-03-21 07:13:59 UTC (rev 166047)
@@ -200,7 +200,7 @@
                     continue;
 
                 tagStart.append("<b>");
-                tagEnd.insert("</b>", 0);
+                tagEnd = "</b>" + tagEnd;
                 continue;
             }
 
@@ -209,7 +209,7 @@
                     continue;
 
                 tagStart.append("<i>");
-                tagEnd.insert("</i>", 0);
+                tagEnd = "</i>" + tagEnd;
                 continue;
             }
 
@@ -218,7 +218,7 @@
                     continue;
 
                 tagStart.append("<u>");
-                tagEnd.insert("</u>", 0);
+                tagEnd = "</u>" + tagEnd;
                 continue;
             }
 

Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp (166046 => 166047)


--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp	2014-03-21 07:12:07 UTC (rev 166046)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp	2014-03-21 07:13:59 UTC (rev 166047)
@@ -56,6 +56,7 @@
 #include <runtime/Uint8Array.h>
 #include <wtf/MainThread.h>
 #include <wtf/text/CString.h>
+#include <wtf/text/StringBuilder.h>
 #include <yarr/RegularExpression.h>
 
 #if PLATFORM(IOS)
@@ -1309,7 +1310,7 @@
 
     JSC::Yarr::RegularExpression regExp("webgl_[0123456789abcdefABCDEF]+", TextCaseSensitive);
 
-    String processedLog;
+    StringBuilder processedLog;
     
     int startFrom = 0;
     int matchedLength = 0;
@@ -1329,8 +1330,8 @@
 
     processedLog.append(log.substring(startFrom, log.length() - startFrom));
 
-    LOG(WebGL, "-->: %s", processedLog.utf8().data());
-    return processedLog;
+    LOG(WebGL, "-->: %s", processedLog.toString().utf8().data());
+    return processedLog.toString();
 }
 
 String GraphicsContext3D::getProgramInfoLog(Platform3DObject program)

Modified: trunk/Source/WebCore/platform/network/MIMEHeader.cpp (166046 => 166047)


--- trunk/Source/WebCore/platform/network/MIMEHeader.cpp	2014-03-21 07:12:07 UTC (rev 166046)
+++ trunk/Source/WebCore/platform/network/MIMEHeader.cpp	2014-03-21 07:13:59 UTC (rev 166047)
@@ -96,9 +96,8 @@
                 LOG_ERROR("No boundary found in multipart MIME header.");
                 return 0;
             }
-            mimeHeader->m_endOfPartBoundary.insert("--", 0);
-            mimeHeader->m_endOfDocumentBoundary = mimeHeader->m_endOfPartBoundary;
-            mimeHeader->m_endOfDocumentBoundary.append("--");
+            mimeHeader->m_endOfPartBoundary = "--" + mimeHeader->m_endOfPartBoundary;
+            mimeHeader->m_endOfDocumentBoundary = mimeHeader->m_endOfPartBoundary + "--";
         }
     }
 

Modified: trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp (166046 => 166047)


--- trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp	2014-03-21 07:12:07 UTC (rev 166046)
+++ trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp	2014-03-21 07:13:59 UTC (rev 166047)
@@ -326,7 +326,7 @@
 
     HTTPHeaderMap::AddResult result = m_httpHeaderFields.add(name, value);
     if (!result.isNewEntry)
-        result.iterator->value.append(", " + value);
+        result.iterator->value = result.iterator->value + ", " + value;
 }
 
 const HTTPHeaderMap& ResourceResponseBase::httpHeaderFields() const

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (166046 => 166047)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2014-03-21 07:12:07 UTC (rev 166046)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2014-03-21 07:13:59 UTC (rev 166047)
@@ -1593,11 +1593,8 @@
 
     // The true root layer is not included in the dump, so if we want to report
     // its repaint rects, they must be included here.
-    if (flags & LayerTreeFlagsIncludeRepaintRects) {
-        String layerTreeTextWithRootRepaintRects = m_renderView.frameView().trackedRepaintRectsAsText();
-        layerTreeTextWithRootRepaintRects.append(layerTreeText);
-        return layerTreeTextWithRootRepaintRects;
-    }
+    if (flags & LayerTreeFlagsIncludeRepaintRects)
+        return m_renderView.frameView().trackedRepaintRectsAsText() + layerTreeText;
 
     return layerTreeText;
 }

Modified: trunk/Source/WebCore/rendering/RenderText.cpp (166046 => 166047)


--- trunk/Source/WebCore/rendering/RenderText.cpp	2014-03-21 07:12:07 UTC (rev 166046)
+++ trunk/Source/WebCore/rendering/RenderText.cpp	2014-03-21 07:13:59 UTC (rev 166047)
@@ -1088,11 +1088,11 @@
 
     int lastTypedCharacterOffsetToReveal = -1;
     String revealedText;
-    SecureTextTimer* secureTextTimer = gSecureTextTimers ? gSecureTextTimers->get(this) : 0;
+    SecureTextTimer* secureTextTimer = gSecureTextTimers ? gSecureTextTimers->get(this) : nullptr;
     if (secureTextTimer && secureTextTimer->isActive()) {
         lastTypedCharacterOffsetToReveal = secureTextTimer->lastTypedCharacterOffset();
         if (lastTypedCharacterOffsetToReveal >= 0)
-            revealedText.append(m_text[lastTypedCharacterOffsetToReveal]);
+            revealedText = m_text.substring(lastTypedCharacterOffsetToReveal, 1);
     }
 
     m_text.fill(mask);

Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (166046 => 166047)


--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2014-03-21 07:12:07 UTC (rev 166046)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2014-03-21 07:13:59 UTC (rev 166047)
@@ -974,7 +974,7 @@
 {
     HTTPHeaderMap::AddResult result = m_requestHeaders.add(name, value);
     if (!result.isNewEntry)
-        result.iterator->value.append(", " + value);
+        result.iterator->value = result.iterator->value + ", " + value;
 }
 
 String XMLHttpRequest::getRequestHeader(const AtomicString& name) const

Modified: trunk/Source/WebKit/mac/ChangeLog (166046 => 166047)


--- trunk/Source/WebKit/mac/ChangeLog	2014-03-21 07:12:07 UTC (rev 166046)
+++ trunk/Source/WebKit/mac/ChangeLog	2014-03-21 07:13:59 UTC (rev 166047)
@@ -1,5 +1,15 @@
 2014-03-21  Darin Adler  <[email protected]>
 
+        Improve idiom used for string building in a few places
+        https://bugs.webkit.org/show_bug.cgi?id=130561
+
+        Reviewed by Andreas Kling.
+
+        * WebView/WebHTMLRepresentation.mm:
+        (regExpForLabels): Use StringBuilder.
+
+2014-03-21  Darin Adler  <[email protected]>
+
         Add a combined decodeAndFlush to TextResourceDecoder
         https://bugs.webkit.org/show_bug.cgi?id=130560
 

Modified: trunk/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm (166046 => 166047)


--- trunk/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm	2014-03-21 07:12:07 UTC (rev 166046)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm	2014-03-21 07:13:59 UTC (rev 166047)
@@ -63,6 +63,7 @@
 #import <yarr/RegularExpression.h>
 #import <wtf/Assertions.h>
 #import <wtf/StdLibExtras.h>
+#import <wtf/text/StringBuilder.h>
 
 using namespace WebCore;
 using namespace HTMLNames;
@@ -373,9 +374,10 @@
     if (cacheHit != NSNotFound)
         result = regExps.at(cacheHit);
     else {
-        String pattern("(");
-        unsigned int numLabels = [labels count];
-        unsigned int i;
+        StringBuilder pattern;
+        pattern.append('(');
+        unsigned numLabels = [labels count];
+        unsigned i;
         for (i = 0; i < numLabels; i++) {
             String label = [labels objectAtIndex:i];
 
@@ -387,18 +389,18 @@
             }
             
             if (i != 0)
-                pattern.append("|");
+                pattern.append('|');
             // Search for word boundaries only if label starts/ends with "word characters".
             // If we always searched for word boundaries, this wouldn't work for languages
             // such as Japanese.
             if (startsWithWordChar)
-                pattern.append("\\b");
+                pattern.appendLiteral("\\b");
             pattern.append(label);
             if (endsWithWordChar)
-                pattern.append("\\b");
+                pattern.appendLiteral("\\b");
         }
-        pattern.append(")");
-        result = new RegularExpression(pattern, TextCaseInsensitive);
+        pattern.append(')');
+        result = new RegularExpression(pattern.toString(), TextCaseInsensitive);
     }
 
     // add regexp to the cache, making sure it is at the front for LRU ordering

Modified: trunk/Source/WebKit2/ChangeLog (166046 => 166047)


--- trunk/Source/WebKit2/ChangeLog	2014-03-21 07:12:07 UTC (rev 166046)
+++ trunk/Source/WebKit2/ChangeLog	2014-03-21 07:13:59 UTC (rev 166047)
@@ -1,3 +1,17 @@
+2014-03-21  Darin Adler  <[email protected]>
+
+        Improve idiom used for string building in a few places
+        https://bugs.webkit.org/show_bug.cgi?id=130561
+
+        Reviewed by Andreas Kling.
+
+        * Shared/mac/ChildProcessMac.mm:
+        (WebKit::ChildProcess::initializeSandbox): Use a more efficient idiom for string
+        concatenation.
+
+        * UIProcess/WebInspectorProxy.cpp:
+        (WebKit::WebInspectorProxy::createInspectorPage): Use a StringBuilder.
+
 2014-03-20  Hyowon Kim  <[email protected]>
 
         Move to using std::unique_ptr for EFL objects.

Modified: trunk/Source/WebKit2/Shared/mac/ChildProcessMac.mm (166046 => 166047)


--- trunk/Source/WebKit2/Shared/mac/ChildProcessMac.mm	2014-03-21 07:12:07 UTC (rev 166046)
+++ trunk/Source/WebKit2/Shared/mac/ChildProcessMac.mm	2014-03-21 07:13:59 UTC (rev 166047)
@@ -104,15 +104,13 @@
     }
 
     Vector<String> osVersionParts;
-    String osSystemMarketingVersion = String(systemMarketingVersion());
+    String osSystemMarketingVersion = systemMarketingVersion();
     osSystemMarketingVersion.split('.', false, osVersionParts);
     if (osVersionParts.size() < 2) {
         WTFLogAlways("%s: Couldn't find OS Version\n", getprogname());
         exit(EX_NOPERM);
     }
-    String osVersion = osVersionParts[0];
-    osVersion.append('.');
-    osVersion.append(osVersionParts[1]);
+    String osVersion = osVersionParts[0] + '.' + osVersionParts[1];
     sandboxParameters.addParameter("_OS_VERSION", osVersion.utf8().data());
 
 #if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080

Modified: trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp (166046 => 166047)


--- trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp	2014-03-21 07:12:07 UTC (rev 166046)
+++ trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp	2014-03-21 07:13:59 UTC (rev 166047)
@@ -41,6 +41,7 @@
 #include "WebProcessProxy.h"
 #include <WebCore/SchemeRegistry.h>
 #include <wtf/NeverDestroyed.h>
+#include <wtf/text/StringBuilder.h>
 
 #if ENABLE(INSPECTOR_SERVER)
 #include "WebInspectorServer.h"
@@ -462,27 +463,29 @@
 
     WKPageSetPagePolicyClient(toAPI(inspectorPage), &policyClient.base);
 
-    String url = ""
+    StringBuilder url;
 
-    url.append("?dockSide=");
+    url.append(inspectorPageURL());
 
+    url.appendLiteral("?dockSide=");
+
     if (m_isAttached) {
         switch (m_attachmentSide) {
         case AttachmentSideBottom:
-            url.append("bottom");
+            url.appendLiteral("bottom");
             m_page->process().send(Messages::WebInspector::AttachedBottom(), m_page->pageID());
             break;
         case AttachmentSideRight:
-            url.append("right");
+            url.appendLiteral("right");
             m_page->process().send(Messages::WebInspector::AttachedRight(), m_page->pageID());
             break;
         }
     } else
-        url.append("undocked");
+        url.appendLiteral("undocked");
 
     m_page->process().assumeReadAccessToBaseURL(inspectorBaseURL());
 
-    inspectorPage->loadRequest(URL(URL(), url));
+    inspectorPage->loadRequest(URL(URL(), url.toString()));
 
     m_createdInspectorPage = true;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to