Title: [121523] trunk/Source/WebCore
Revision
121523
Author
[email protected]
Date
2012-06-29 00:06:45 -0700 (Fri, 29 Jun 2012)

Log Message

Use StringBuilder in SegmentedString::toString()
https://bugs.webkit.org/show_bug.cgi?id=90247

Patch by Kwang Yul Seo <[email protected]> on 2012-06-29
Reviewed by Adam Barth.

Use a StringBuilder instead of String concatenation because StringBuilder is generally faster.
No new tests. Covered by existing tests.

* platform/text/SegmentedString.cpp:
(WebCore::SegmentedString::toString):
* platform/text/SegmentedString.h:
(WebCore::SegmentedSubstring::appendTo):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (121522 => 121523)


--- trunk/Source/WebCore/ChangeLog	2012-06-29 06:54:37 UTC (rev 121522)
+++ trunk/Source/WebCore/ChangeLog	2012-06-29 07:06:45 UTC (rev 121523)
@@ -1,3 +1,18 @@
+2012-06-29  Kwang Yul Seo  <[email protected]>
+
+        Use StringBuilder in SegmentedString::toString()
+        https://bugs.webkit.org/show_bug.cgi?id=90247
+
+        Reviewed by Adam Barth.
+
+        Use a StringBuilder instead of String concatenation because StringBuilder is generally faster.
+        No new tests. Covered by existing tests.
+
+        * platform/text/SegmentedString.cpp:
+        (WebCore::SegmentedString::toString):
+        * platform/text/SegmentedString.h:
+        (WebCore::SegmentedSubstring::appendTo):
+
 2012-06-28  Ryosuke Niwa  <[email protected]>
 
         Mac build fix after r121518.

Modified: trunk/Source/WebCore/platform/text/SegmentedString.cpp (121522 => 121523)


--- trunk/Source/WebCore/platform/text/SegmentedString.cpp	2012-06-29 06:54:37 UTC (rev 121522)
+++ trunk/Source/WebCore/platform/text/SegmentedString.cpp	2012-06-29 07:06:45 UTC (rev 121523)
@@ -184,7 +184,7 @@
 
 String SegmentedString::toString() const
 {
-    String result;
+    StringBuilder result;
     if (m_pushedChar1) {
         result.append(m_pushedChar1);
         if (m_pushedChar2)
@@ -197,7 +197,7 @@
         for (; it != e; ++it)
             it->appendTo(result);
     }
-    return result;
+    return result.toString();
 }
 
 void SegmentedString::advance(unsigned count, UChar* consumedCharacters)

Modified: trunk/Source/WebCore/platform/text/SegmentedString.h (121522 => 121523)


--- trunk/Source/WebCore/platform/text/SegmentedString.h	2012-06-29 06:54:37 UTC (rev 121522)
+++ trunk/Source/WebCore/platform/text/SegmentedString.h	2012-06-29 07:06:45 UTC (rev 121523)
@@ -22,6 +22,7 @@
 
 #include "PlatformString.h"
 #include <wtf/Deque.h>
+#include <wtf/text/StringBuilder.h>
 #include <wtf/text/TextPosition.h>
 
 namespace WebCore {
@@ -54,15 +55,12 @@
 
     int numberOfCharactersConsumed() const { return m_string.length() - m_length; }
 
-    void appendTo(String& str) const
+    void appendTo(StringBuilder& builder) const
     {
-        if (m_string.characters() == m_current) {
-            if (str.isEmpty())
-                str = m_string;
-            else
-                str.append(m_string);
-        } else
-            str.append(String(m_current, m_length));
+        if (m_string.characters() == m_current)
+            builder.append(m_string);
+        else
+            builder.append(String(m_current, m_length));
     }
 
 public:
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to