writeHelperGetString in V8HTMLDocument uses += to concatenate strings
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Aug 2012 01:10:01 +0000 (01:10 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Aug 2012 01:10:01 +0000 (01:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=93035

Patch by Jae Hyun Park <jae.park@company100.net> on 2012-08-08
Reviewed by Adam Barth.

Use a StringBuilder instead of String concatenation because StringBuilder is generally faster.

No new functionality, so no new tests.

* bindings/v8/custom/V8HTMLDocumentCustom.cpp:
(WebCore::writeHelperGetString):

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

Source/WebCore/ChangeLog
Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp

index 2c46383..a45e5cc 100644 (file)
@@ -1,3 +1,17 @@
+2012-08-08  Jae Hyun Park  <jae.park@company100.net>
+
+        writeHelperGetString in V8HTMLDocument uses += to concatenate strings
+        https://bugs.webkit.org/show_bug.cgi?id=93035
+
+        Reviewed by Adam Barth.
+
+        Use a StringBuilder instead of String concatenation because StringBuilder is generally faster.
+
+        No new functionality, so no new tests.
+
+        * bindings/v8/custom/V8HTMLDocumentCustom.cpp:
+        (WebCore::writeHelperGetString):
+
 2012-08-08  Adrienne Walker  <enne@google.com>
 
         [chromium] Move scrollbar pointer into WebScrollbarThemePainter
index c2150a0..0d421f9 100644 (file)
@@ -46,6 +46,7 @@
 #include "V8Node.h"
 #include "V8Proxy.h"
 #include "V8RecursionScope.h"
+#include <wtf/text/StringBuilder.h>
 #include <wtf/OwnArrayPtr.h>
 #include <wtf/RefPtr.h>
 #include <wtf/StdLibExtras.h>
@@ -109,10 +110,10 @@ v8::Handle<v8::Value> V8HTMLDocument::GetNamedProperty(HTMLDocument* htmlDocumen
 //   document.write() --> document.write("")
 static String writeHelperGetString(const v8::Arguments& args)
 {
-    String str = "";
+    StringBuilder builder;
     for (int i = 0; i < args.Length(); ++i)
-        str += toWebCoreString(args[i]);
-    return str;
+        builder.append(toWebCoreString(args[i]));
+    return builder.toString();
 }
 
 v8::Handle<v8::Value> V8HTMLDocument::writeCallback(const v8::Arguments& args)