Atomicize frequently identical ResourceResponse string members.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 16 Feb 2014 22:59:55 +0000 (22:59 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 16 Feb 2014 22:59:55 +0000 (22:59 +0000)
<https://webkit.org/b/128887>

Store the mime type, text encoding and HTTP response status text in
AtomicStrings instead of Strings to deduplicate frequently occurring
values (e.g "text/html", "utf-8" and "OK".)

Reviewed by Geoffrey Garen.

* platform/network/ResourceResponseBase.h:
* platform/network/cf/ResourceResponseCFNet.cpp:
(WebCore::ResourceResponse::cfURLResponse):
(WebCore::ResourceResponse::platformLazyInit):
* platform/network/mac/ResourceResponseMac.mm:
(WebCore::ResourceResponse::platformLazyInit):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/network/ResourceResponseBase.h
Source/WebCore/platform/network/cf/ResourceResponseCFNet.cpp
Source/WebCore/platform/network/mac/ResourceResponseMac.mm

index 53a821484bf2f66454aab2d149326b1374322c8b..c6174e0ede606fa91ee66c2b110e975ed8718c1a 100644 (file)
@@ -1,3 +1,21 @@
+2014-02-16  Andreas Kling  <akling@apple.com>
+
+        Atomicize frequently identical ResourceResponse string members.
+        <https://webkit.org/b/128887>
+
+        Store the mime type, text encoding and HTTP response status text in
+        AtomicStrings instead of Strings to deduplicate frequently occurring
+        values (e.g "text/html", "utf-8" and "OK".)
+
+        Reviewed by Geoffrey Garen.
+
+        * platform/network/ResourceResponseBase.h:
+        * platform/network/cf/ResourceResponseCFNet.cpp:
+        (WebCore::ResourceResponse::cfURLResponse):
+        (WebCore::ResourceResponse::platformLazyInit):
+        * platform/network/mac/ResourceResponseMac.mm:
+        (WebCore::ResourceResponse::platformLazyInit):
+
 2014-02-16  Dan Bernstein  <mitz@apple.com>
 
         Speculative iOS build fix.
index 9d838acc49703710af7c7cddadf2f36e3d990f9b..757032f6cc65a16054033a745139cc4489506cee 100644 (file)
@@ -141,11 +141,11 @@ protected:
     static bool platformCompare(const ResourceResponse&, const ResourceResponse&) { return true; }
 
     URL m_url;
-    String m_mimeType;
+    AtomicString m_mimeType;
     long long m_expectedContentLength;
-    String m_textEncodingName;
+    AtomicString m_textEncodingName;
     String m_suggestedFilename;
-    String m_httpStatusText;
+    AtomicString m_httpStatusText;
     HTTPHeaderMap m_httpHeaderFields;
     RefPtr<ResourceLoadTiming> m_resourceLoadTiming;
 
index 335f72fd2e6e74066bbf6967017a0c9215173e26..42aeee8d21a710fef17619e18fbc548e5c8c8f15 100644 (file)
@@ -52,7 +52,7 @@ CFURLResponseRef ResourceResponse::cfURLResponse() const
 
         // FIXME: This creates a very incomplete CFURLResponse, which does not even have a status code.
 
-        m_cfResponse = adoptCF(CFURLResponseCreate(0, url.get(), m_mimeType.createCFString().get(), m_expectedContentLength, m_textEncodingName.createCFString().get(), kCFURLCacheStorageAllowed));
+        m_cfResponse = adoptCF(CFURLResponseCreate(0, url.get(), m_mimeType.string().createCFString().get(), m_expectedContentLength, m_textEncodingName.string().createCFString().get(), kCFURLCacheStorageAllowed));
     }
 
     return m_cfResponse.get();
@@ -75,7 +75,7 @@ void ResourceResponse::platformLazyInit(InitLevel initLevel)
         // Workaround for <rdar://problem/8757088>, can be removed once that is fixed.
         unsigned textEncodingNameLength = m_textEncodingName.length();
         if (textEncodingNameLength >= 2 && m_textEncodingName[0U] == '"' && m_textEncodingName[textEncodingNameLength - 1] == '"')
-            m_textEncodingName = m_textEncodingName.substring(1, textEncodingNameLength - 2);
+            m_textEncodingName = m_textEncodingName.string().substring(1, textEncodingNameLength - 2);
 
         CFHTTPMessageRef httpResponse = CFURLResponseGetHTTPResponse(m_cfResponse.get());
         if (httpResponse) {
index 3ff8bd2dafbc939601e6368bf3cd9e8fe162304e..e3f689bceb7acdf2089d8db2fccfbd8604e2ea85 100644 (file)
@@ -120,7 +120,7 @@ void ResourceResponse::platformLazyInit(InitLevel initLevel)
         // Workaround for <rdar://problem/8757088>, can be removed once that is fixed.
         unsigned textEncodingNameLength = m_textEncodingName.length();
         if (textEncodingNameLength >= 2 && m_textEncodingName[0U] == '"' && m_textEncodingName[textEncodingNameLength - 1] == '"')
-            m_textEncodingName = m_textEncodingName.substring(1, textEncodingNameLength - 2);
+            m_textEncodingName = m_textEncodingName.string().substring(1, textEncodingNameLength - 2);
 
         if ([m_nsResponse.get() isKindOfClass:[NSHTTPURLResponse class]]) {
             NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)m_nsResponse.get();