More fixes for String::operator+=() on Mac
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Sep 2012 20:31:57 +0000 (20:31 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Sep 2012 20:31:57 +0000 (20:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=95880

Patch by Benjamin Poulain <bpoulain@apple.com> on 2012-09-05
Reviewed by Adam Barth.

Source/WebCore:

Followup for r127574, I forgot some use of strings.

* css/StylePropertySet.cpp:
(WebCore::StylePropertySet::getShorthandValue): Use String builder to construct the shorthand.

Source/WebKit/mac:

* WebView/WebRenderLayer.mm:
(+[WebRenderLayer nameForLayer:]): Use StringBuilder to concatenate the class names
efficiently.
* WebView/WebView.mm:
(+[WebView _decodeData:]): This is a legitimate use of String::append(), there
is no other concatenation done on that string.

Source/WebKit2:

* UIProcess/WebInspectorProxy.cpp:
(WebKit::WebInspectorProxy::createInspectorPage): This is a legitimate use of append(),
there is no other concatenation outside that branch.
* WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
(WebKit::parseRFC822HeaderFields): Use string operators instead of +=.
* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::userAgent): Another legitimate use of append().

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@127639 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/css/StylePropertySet.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebRenderLayer.mm
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebInspectorProxy.cpp
Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp

index 9e6126b..be63ad8 100644 (file)
@@ -1,3 +1,15 @@
+2012-09-05  Benjamin Poulain  <bpoulain@apple.com>
+
+        More fixes for String::operator+=() on Mac
+        https://bugs.webkit.org/show_bug.cgi?id=95880
+
+        Reviewed by Adam Barth.
+
+        Followup for r127574, I forgot some use of strings.
+
+        * css/StylePropertySet.cpp:
+        (WebCore::StylePropertySet::getShorthandValue): Use String builder to construct the shorthand.
+
 2012-09-05  James Robinson  <jamesr@chromium.org>
 
         [chromium] Put webcore_platform_files in separate gyp target instead of relying on exclusion patterns
index d446938..d0f0fab 100644 (file)
@@ -431,7 +431,7 @@ String StylePropertySet::getLayeredShorthandValue(const StylePropertyShorthand&
 
 String StylePropertySet::getShorthandValue(const StylePropertyShorthand& shorthand) const
 {
-    String res;
+    StringBuilder result;
     for (unsigned i = 0; i < shorthand.length(); ++i) {
         if (!isPropertyImplicit(shorthand.properties()[i])) {
             RefPtr<CSSValue> value = getPropertyCSSValue(shorthand.properties()[i]);
@@ -439,12 +439,14 @@ String StylePropertySet::getShorthandValue(const StylePropertyShorthand& shortha
                 return String();
             if (value->isInitialValue())
                 continue;
-            if (!res.isNull())
-                res += " ";
-            res += value->cssText();
+            if (!result.isEmpty())
+                result.append(' ');
+            result.append(value->cssText());
         }
     }
-    return res;
+    if (result.isEmpty())
+        return String();
+    return result.toString();
 }
 
 // only returns a non-null value if all properties have the same, non-null value
index e8b969d..064c22e 100644 (file)
@@ -1,3 +1,17 @@
+2012-09-05  Benjamin Poulain  <bpoulain@apple.com>
+
+        More fixes for String::operator+=() on Mac
+        https://bugs.webkit.org/show_bug.cgi?id=95880
+
+        Reviewed by Adam Barth.
+
+        * WebView/WebRenderLayer.mm:
+        (+[WebRenderLayer nameForLayer:]): Use StringBuilder to concatenate the class names
+        efficiently.
+        * WebView/WebView.mm:
+        (+[WebView _decodeData:]): This is a legitimate use of String::append(), there
+        is no other concatenation done on that string.
+
 2012-09-01  Mark Lam  <mark.lam@apple.com>
 
         Added #include <JavaScriptCore/Identifier.h>.
index c282643..85c1777 100644 (file)
@@ -59,13 +59,13 @@ using namespace WebCore;
 
         if (node->hasClass()) {
             StyledElement* styledElement = static_cast<StyledElement*>(node);
-            String classes;
+            StringBuilder classes;
             for (size_t i = 0; i < styledElement->classNames().size(); ++i) {
                 if (i > 0)
-                    classes += " ";
-                classes += styledElement->classNames()[i];
+                    classes.append(' ');
+                classes.append(styledElement->classNames()[i]);
             }
-            name = [name stringByAppendingFormat:@" class=\"%@\"", (NSString *)classes];
+            name = [name stringByAppendingFormat:@" class=\"%@\"", (NSString *)classes.toString()];
         }
     }
 
index 358c07b..7b8412c 100644 (file)
@@ -1787,7 +1787,7 @@ static inline IMP getMethod(id o, SEL s)
     HTMLNames::init(); // this method is used for importing bookmarks at startup, so HTMLNames are likely to be uninitialized yet
     RefPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("text/html"); // bookmark files are HTML
     String result = decoder->decode(static_cast<const char*>([data bytes]), [data length]);
-    result += decoder->flush();
+    result.append(decoder->flush());
     return result;
 }
 
index ccc68fc..14f4344 100644 (file)
@@ -1,3 +1,18 @@
+2012-09-05  Benjamin Poulain  <bpoulain@apple.com>
+
+        More fixes for String::operator+=() on Mac
+        https://bugs.webkit.org/show_bug.cgi?id=95880
+
+        Reviewed by Adam Barth.
+
+        * UIProcess/WebInspectorProxy.cpp:
+        (WebKit::WebInspectorProxy::createInspectorPage): This is a legitimate use of append(),
+        there is no other concatenation outside that branch.
+        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
+        (WebKit::parseRFC822HeaderFields): Use string operators instead of +=.
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::NetscapePlugin::userAgent): Another legitimate use of append().
+
 2012-09-05  Alexey Proskuryakov  <ap@apple.com>
 
         [WK2] Make visited link tracking work in multi-process mode
index 52c0b74..4ef85f2 100644 (file)
@@ -329,7 +329,7 @@ void WebInspectorProxy::createInspectorPage(uint64_t& inspectorPageID, WebPageCr
 
     String url = inspectorPageURL();
     if (m_isAttached)
-        url += "?docked=true";
+        url.append("?docked=true");
 
     m_page->process()->assumeReadAccessToBaseURL(inspectorBaseURL());
 
index d40db79..ebf4db8 100644 (file)
@@ -203,12 +203,8 @@ static HTTPHeaderMap parseRFC822HeaderFields(const char* bytes, unsigned length)
                 value = String(colon, endOfLine - colon);
             
             String oldValue = headerFields.get(lastHeaderKey);
-            if (!oldValue.isNull()) {
-                String tmp = oldValue;
-                tmp += ", ";
-                tmp += value;
-                value = tmp;
-            }
+            if (!oldValue.isNull())
+                value = oldValue + ", " + value;
             
             headerFields.set(lastHeaderKey, value);
         }
index 0e7f5e0..15e7648 100644 (file)
@@ -161,7 +161,7 @@ const char* NetscapePlugin::userAgent()
 
 #if PLUGIN_ARCHITECTURE(MAC)
         if (quirks().contains(PluginQuirks::AppendVersion3UserAgent))
-            userAgent += " Version/3.2.1";
+            userAgent.append(" Version/3.2.1");
 #endif
 
         m_userAgent = userAgent.utf8();