Title: [125367] trunk/Source/WebCore
Revision
125367
Author
[email protected]
Date
2012-08-12 03:37:15 -0700 (Sun, 12 Aug 2012)

Log Message

CSSComputedStyleDeclaration::cssText() should use StringBuilder
https://bugs.webkit.org/show_bug.cgi?id=93776

Reviewed by Eric Seidel.

String::append() is fairly inefficient when used to create a long string by appending a lot of small
pieces. StringBuilder is more approriate for the kind of operations done by CSSComputedStyleDeclaration::cssText().

This changes makes CSSComputedStyleDeclaration::cssText() about 6 times faster.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::cssText):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (125366 => 125367)


--- trunk/Source/WebCore/ChangeLog	2012-08-12 07:32:26 UTC (rev 125366)
+++ trunk/Source/WebCore/ChangeLog	2012-08-12 10:37:15 UTC (rev 125367)
@@ -1,3 +1,18 @@
+2012-08-12  Benjamin Poulain  <[email protected]>
+
+        CSSComputedStyleDeclaration::cssText() should use StringBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=93776
+
+        Reviewed by Eric Seidel.
+
+        String::append() is fairly inefficient when used to create a long string by appending a lot of small
+        pieces. StringBuilder is more approriate for the kind of operations done by CSSComputedStyleDeclaration::cssText().
+
+        This changes makes CSSComputedStyleDeclaration::cssText() about 6 times faster.
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::cssText):
+
 2012-08-11  Benjamin Poulain  <[email protected]>
 
         Do the DecimalNumber to String conversion on 8 bits

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (125366 => 125367)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2012-08-12 07:32:26 UTC (rev 125366)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2012-08-12 10:37:15 UTC (rev 125367)
@@ -57,6 +57,7 @@
 #include "StylePropertyShorthand.h"
 #include "WebKitCSSTransformValue.h"
 #include "WebKitFontFamilyNames.h"
+#include <wtf/text/StringBuilder.h>
 
 #if ENABLE(CSS_EXCLUSIONS)
 #include "CSSWrapShapes.h"
@@ -1061,18 +1062,18 @@
 
 String CSSComputedStyleDeclaration::cssText() const
 {
-    String result("");
+    StringBuilder result;
 
     for (unsigned i = 0; i < numComputedProperties; i++) {
         if (i)
-            result += " ";
-        result += getPropertyName(computedProperties[i]);
-        result += ": ";
-        result += getPropertyValue(computedProperties[i]);
-        result += ";";
+            result.append(' ');
+        result.append(getPropertyName(computedProperties[i]));
+        result.append(": ", 2);
+        result.append(getPropertyValue(computedProperties[i]));
+        result.append(';');
     }
 
-    return result;
+    return result.toString();
 }
 
 void CSSComputedStyleDeclaration::setCssText(const String&, ExceptionCode& ec)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to