Reviewed by Anders.
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Oct 2006 10:34:24 +0000 (10:34 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Oct 2006 10:34:24 +0000 (10:34 +0000)
        - .5% speed improvement by avoiding excess CFURLRef allocation

        * loader/CachedResource.cpp:
        (WebCore::CachedResource::getCFURL): New method. For Mac only (for now), cache the CFURL
        here for later reuse.
        * loader/CachedResource.h:
        * loader/mac/LoaderFunctionsMac.mm:
        (WebCore::CheckCacheObjectStatus): Use the cached CFURL, don't make a whole new one.

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

WebCore/ChangeLog
WebCore/loader/CachedResource.cpp
WebCore/loader/CachedResource.h
WebCore/loader/mac/LoaderFunctionsMac.mm

index b1f1ebd7d476d91364aa8bbee2d7022f4aaaa63e..edc38376f3f873148619eda783215c05454faee8 100644 (file)
@@ -1,3 +1,16 @@
+2006-10-26  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Anders.
+
+        - .5% speed improvement by avoiding excess CFURLRef allocation
+
+        * loader/CachedResource.cpp:
+        (WebCore::CachedResource::getCFURL): New method. For Mac only (for now), cache the CFURL
+        here for later reuse.
+        * loader/CachedResource.h:
+        * loader/mac/LoaderFunctionsMac.mm:
+        (WebCore::CheckCacheObjectStatus): Use the cached CFURL, don't make a whole new one.
+
 2006-10-25  Darin Adler  <darin@apple.com>
 
         Reviewed by Anders.
index 4a69e98f10228cda4a6d964aea52569cf48d52be..117a244f3bec7907ca6c30e8d59c9d20208e5723 100644 (file)
 #include <KURL.h>
 #include <wtf/Vector.h>
 
+#if PLATFORM(MAC)
+#include <CoreFoundation/CoreFoundation.h>
+#endif
+
 namespace WebCore {
 
 CachedResource::CachedResource(const String& URL, Type type, CachePolicy cachePolicy, time_t expireDate, unsigned size)
@@ -161,4 +165,16 @@ void CachedResource::setSize(unsigned size)
     }
 }
 
+#if PLATFORM(MAC)
+CFURLRef CachedResource::getCFURL()
+{
+    if (!m_cfURL) {
+        m_cfURL = KURL(url().deprecatedString()).createCFURL();
+        CFRelease(m_cfURL.get());
+    }
+        
+    return m_cfURL.get();    
+}
+#endif
+
 }
index 1deaaa8fbcb6677e8db26b23aaf4065c798883d5..1d743648e60132394d753b6e7d081020068a4efd 100644 (file)
 #include <wtf/Vector.h>
 #include <time.h>
 
+#if PLATFORM(MAC)
+#include "RetainPtr.h"
+#endif
+
 namespace WebCore {
 
 class Cache;
@@ -127,6 +131,10 @@ public:
     String accept() const { return m_accept; }
     void setAccept(const String& accept) { m_accept = accept; }
 
+#if PLATFORM(MAC)
+    CFURLRef getCFURL();
+#endif
+
 protected:
     void setSize(unsigned size);
 
@@ -136,6 +144,10 @@ protected:
     String m_accept;
     Request* m_request;
 
+#if PLATFORM(MAC)
+    RetainPtr<CFURLRef> m_cfURL;
+#endif
+
     PlatformResponse m_response;
     PlatformData m_allData;
 
index b56c0630c12ca462a664f0ce2f33cb6e7c9a90cc..dfaef24e0f89e7fd25615c12befdad01a7a66e36 100644 (file)
@@ -168,7 +168,7 @@ void CheckCacheObjectStatus(DocLoader *loader, CachedResource *cachedObject)
         WebCoreFrameBridge *bridge = frame->bridge();
         
         BEGIN_BLOCK_OBJC_EXCEPTIONS;
-        [bridge objectLoadedFromCacheWithURL:KURL(cachedObject->url().deprecatedString()).getNSURL()
+        [bridge objectLoadedFromCacheWithURL:(NSURL *)cachedObject->getCFURL()
                                     response:(NSURLResponse *)cachedObject->response()
                                         data:(NSData *)cachedObject->allData()];
         END_BLOCK_OBJC_EXCEPTIONS;