Title: [127828] trunk/Source/WebKit2
Revision
127828
Author
[email protected]
Date
2012-09-06 22:34:33 -0700 (Thu, 06 Sep 2012)

Log Message

Deploy StringBuilder in more places in WebKit2
https://bugs.webkit.org/show_bug.cgi?id=95924

Patch by Jinwoo Song <[email protected]> on 2012-09-06
Reviewed by Benjamin Poulain.

Deploy StringBuilder to concatenate strings more efficiently.

* Shared/WebMemorySampler.cpp:
(WebKit):
(WebKit::WebMemorySampler::WebMemorySampler):
(WebKit::WebMemorySampler::stop):
(WebKit::WebMemorySampler::writeHeaders):
(WebKit::WebMemorySampler::appendCurrentMemoryUsageToFile):
* Shared/WebMemorySampler.h:
(WebMemorySampler):
* WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
(WebKit::capitalizeRFC822HeaderFieldName):
* WebProcess/WebCoreSupport/WebContextMenuClient.cpp:
(WebKit::WebContextMenuClient::searchWithGoogle):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (127827 => 127828)


--- trunk/Source/WebKit2/ChangeLog	2012-09-07 05:32:04 UTC (rev 127827)
+++ trunk/Source/WebKit2/ChangeLog	2012-09-07 05:34:33 UTC (rev 127828)
@@ -1,3 +1,25 @@
+2012-09-06  Jinwoo Song  <[email protected]>
+
+        Deploy StringBuilder in more places in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=95924
+
+        Reviewed by Benjamin Poulain.
+
+        Deploy StringBuilder to concatenate strings more efficiently.
+
+        * Shared/WebMemorySampler.cpp:
+        (WebKit):
+        (WebKit::WebMemorySampler::WebMemorySampler):
+        (WebKit::WebMemorySampler::stop):
+        (WebKit::WebMemorySampler::writeHeaders):
+        (WebKit::WebMemorySampler::appendCurrentMemoryUsageToFile):
+        * Shared/WebMemorySampler.h:
+        (WebMemorySampler):
+        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
+        (WebKit::capitalizeRFC822HeaderFieldName):
+        * WebProcess/WebCoreSupport/WebContextMenuClient.cpp:
+        (WebKit::WebContextMenuClient::searchWithGoogle):
+
 2012-09-06  Ryuan Choi  <[email protected]>
 
         [EFL][WK2] Add API unit tests for ewk_view_theme_set.

Modified: trunk/Source/WebKit2/Shared/WebMemorySampler.cpp (127827 => 127828)


--- trunk/Source/WebKit2/Shared/WebMemorySampler.cpp	2012-09-07 05:32:04 UTC (rev 127827)
+++ trunk/Source/WebKit2/Shared/WebMemorySampler.cpp	2012-09-07 05:34:33 UTC (rev 127828)
@@ -30,11 +30,13 @@
 
 #include <stdio.h>
 #include <wtf/text/CString.h>
+#include <wtf/text/StringBuilder.h>
 
 using namespace WebCore;
 
 namespace WebKit {
 
+static const char separator = '\t';
 
 WebMemorySampler* WebMemorySampler::shared()
 {
@@ -45,8 +47,7 @@
 }
 
 WebMemorySampler::WebMemorySampler() 
-    : m_separator(String("\t"))  
-    , m_sampleTimer(this, &WebMemorySampler::sampleTimerFired)
+    : m_sampleTimer(this, &WebMemorySampler::sampleTimerFired)
     , m_stopTimer(this, &WebMemorySampler::stopTimerFired)
     , m_isRunning(false)
     , m_runningTime(0)
@@ -102,7 +103,7 @@
     fflush(stdout);
     m_isRunning = false;
     
-    if(m_stopTimer.isActive())
+    if (m_stopTimer.isActive())
         m_stopTimer.stop();
     
     if (m_sampleLogSandboxExtension) {
@@ -134,21 +135,22 @@
 
 void WebMemorySampler::writeHeaders()
 {
-    String processDetails = String("Process: ");
-    processDetails.append(processName());
-    processDetails.append(String("\n"));
-    writeToFile(m_sampleLogFile, processDetails.utf8().data(), processDetails.utf8().length());
+    String processDetails = "Process: " + processName() + '\n';
+
+    CString utf8String = processDetails.utf8();
+    writeToFile(m_sampleLogFile, utf8String.data(), utf8String.length());
     
-    String header; 
+    StringBuilder header; 
     WebMemoryStatistics stats = sampleWebKit();
     if (!stats.keys.isEmpty()) {
         for (size_t i = 0; i < stats.keys.size(); ++i) {
-            header.append(m_separator);
-            header.append(stats.keys[i].utf8().data());
+            header.append(separator);
+            header.append(stats.keys[i]);
         }
     }
-    header.append(String("\n"));
-    writeToFile(m_sampleLogFile, header.utf8().data(), header.utf8().length());
+    header.append('\n');
+    utf8String = header.toString().utf8();
+    writeToFile(m_sampleLogFile, utf8String.data(), utf8String.length());
 }
 
 void WebMemorySampler::sampleTimerFired(Timer<WebMemorySampler>*)
@@ -168,18 +170,20 @@
 void WebMemorySampler::appendCurrentMemoryUsageToFile(PlatformFileHandle& file)
 {
     // Collect statistics from allocators and get RSIZE metric
-    String statString; 
+    StringBuilder statString;
     WebMemoryStatistics memoryStats = sampleWebKit();
 
     if (!memoryStats.values.isEmpty()) {
-        statString.append(m_separator);
+        statString.append(separator);
         for (size_t i = 0; i < memoryStats.values.size(); ++i) {
-            statString.append(m_separator);
+            statString.append(separator);
             statString.append(String::number(memoryStats.values[i]));
         }
     }
-    statString.append(String("\n"));
-    writeToFile(m_sampleLogFile, statString.utf8().data(), statString.utf8().length());
+    statString.append('\n');
+
+    CString utf8String = statString.toString().utf8();
+    writeToFile(m_sampleLogFile, utf8String.data(), utf8String.length());
 }
 
 }

Modified: trunk/Source/WebKit2/Shared/WebMemorySampler.h (127827 => 127828)


--- trunk/Source/WebKit2/Shared/WebMemorySampler.h	2012-09-07 05:32:04 UTC (rev 127827)
+++ trunk/Source/WebKit2/Shared/WebMemorySampler.h	2012-09-07 05:34:33 UTC (rev 127828)
@@ -52,19 +52,18 @@
 #if ENABLE(MEMORY_SAMPLER)
 
 #include "SandboxExtension.h"
-#include <WebCore/Timer.h>
 #include <WebCore/FileSystem.h>
+#include <WebCore/Timer.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/RefPtr.h>
-#include <wtf/text/WTFString.h>
 #include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
 
 namespace WebKit {
 
 struct SystemMallocStats;
 
-struct WebMemoryStatistics
-{
+struct WebMemoryStatistics {
     Vector<String> keys;
     Vector<size_t> values;
 };
@@ -73,8 +72,8 @@
     WTF_MAKE_NONCOPYABLE(WebMemorySampler);
 public:
     static WebMemorySampler* shared();
-    void start(const double interval=0);
-    void start(const SandboxExtension::Handle&, const String&, const double interval=0);
+    void start(const double interval = 0);
+    void start(const SandboxExtension::Handle&, const String&, const double interval = 0);
     void stop();
     bool isRunning() const;
     
@@ -98,7 +97,6 @@
     
     WebCore::PlatformFileHandle m_sampleLogFile;
     String m_sampleLogFilePath;
-    String m_separator;
     WebCore::Timer<WebMemorySampler> m_sampleTimer;
     WebCore::Timer<WebMemorySampler> m_stopTimer;
     bool m_isRunning;

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp (127827 => 127828)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp	2012-09-07 05:32:04 UTC (rev 127827)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp	2012-09-07 05:34:33 UTC (rev 127828)
@@ -37,6 +37,7 @@
 #include <WebCore/ProtectionSpace.h>
 #include <WebCore/SharedBuffer.h>
 #include <utility>
+#include <wtf/text/StringBuilder.h>
 
 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
 #include "NetscapeSandboxFunctions.h"
@@ -123,7 +124,7 @@
 static String capitalizeRFC822HeaderFieldName(const String& name)
 {
     bool capitalizeCharacter = true;
-    String result;
+    StringBuilder result;
 
     for (unsigned i = 0; i < name.length(); i++) {
         UChar c;
@@ -143,7 +144,7 @@
         result.append(c);
     }
 
-    return result;
+    return result.toString();
 }
 
 static HTTPHeaderMap parseRFC822HeaderFields(const char* bytes, unsigned length)

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.cpp (127827 => 127828)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.cpp	2012-09-07 05:32:04 UTC (rev 127827)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.cpp	2012-09-07 05:34:33 UTC (rev 127828)
@@ -81,9 +81,7 @@
     String encoded = encodeWithURLEscapeSequences(searchString);
     encoded.replace("%20", "+");
     
-    String url("http://www.google.com/search?q=");
-    url.append(encoded);
-    url.append("&ie=UTF-8&oe=UTF-8");
+    String url = "" + encoded + "&ie=UTF-8&oe=UTF-8";
 
     if (Page* page = frame->page()) {
         UserGestureIndicator indicator(DefinitelyProcessingUserGesture);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to