Title: [175154] trunk/Source/WebCore
Revision
175154
Author
cdu...@apple.com
Date
2014-10-23 18:29:46 -0700 (Thu, 23 Oct 2014)

Log Message

[Mac] Optimize URL::createCFURL() for the common case
https://bugs.webkit.org/show_bug.cgi?id=138030

Reviewed by Alexey Proskuryakov.

Optimize URL::createCFURL() for the common case by adding a fast path
for when the URL String is already 8-bit (common case).
When the string is 8-bit, we don't need to copy the bytes into a
temporary buffer and we can construct the CFURLRef directly from it.

This makes URL::createCFURL() ~34% faster on my machine.

No new tests, no behavior change.

* platform/mac/URLMac.mm:
(WebCore::URL::createCFURL):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (175153 => 175154)


--- trunk/Source/WebCore/ChangeLog	2014-10-24 00:44:09 UTC (rev 175153)
+++ trunk/Source/WebCore/ChangeLog	2014-10-24 01:29:46 UTC (rev 175154)
@@ -1,3 +1,22 @@
+2014-10-23  Chris Dumez  <cdu...@apple.com>
+
+        [Mac] Optimize URL::createCFURL() for the common case
+        https://bugs.webkit.org/show_bug.cgi?id=138030
+
+        Reviewed by Alexey Proskuryakov.
+
+        Optimize URL::createCFURL() for the common case by adding a fast path
+        for when the URL String is already 8-bit (common case).
+        When the string is 8-bit, we don't need to copy the bytes into a
+        temporary buffer and we can construct the CFURLRef directly from it.
+
+        This makes URL::createCFURL() ~34% faster on my machine.
+
+        No new tests, no behavior change.
+
+        * platform/mac/URLMac.mm:
+        (WebCore::URL::createCFURL):
+
 2014-10-23  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Carets in GMail and iCloud compositions are the foreground text color

Modified: trunk/Source/WebCore/platform/mac/URLMac.mm (175153 => 175154)


--- trunk/Source/WebCore/platform/mac/URLMac.mm	2014-10-24 00:44:09 UTC (rev 175153)
+++ trunk/Source/WebCore/platform/mac/URLMac.mm	2014-10-24 01:29:46 UTC (rev 175154)
@@ -62,6 +62,11 @@
         return reinterpret_cast<CFURLRef>(adoptNS([[NSURL alloc] initWithString:@""]).get());
     }
 
+    // Fast path if the input data is 8-bit to avoid copying into a temporary buffer.
+    if (LIKELY(m_string.is8Bit()))
+        return createCFURLFromBuffer(reinterpret_cast<const char*>(m_string.characters8()), m_string.length());
+
+    // Slower path.
     URLCharBuffer buffer;
     copyToBuffer(buffer);
     return createCFURLFromBuffer(buffer.data(), buffer.size());
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to