Title: [232268] trunk/Source/WebCore
Revision
232268
Author
cdu...@apple.com
Date
2018-05-29 11:32:00 -0700 (Tue, 29 May 2018)

Log Message

Avoid unnecessary String allocation in isPublicSuffix(const String&)
https://bugs.webkit.org/show_bug.cgi?id=186054

Reviewed by Sam Weinig.

Avoid unnecessary String allocation in isPublicSuffix(const String&) by calling directly
the decodeHostName() overload taking in a NSString*. This overload returns a NSString*,
which is what we need. We would previously call the overloading taking in a String, which
would return a String, which we would have to convert back to a NSString*.

* platform/mac/PublicSuffixMac.mm:
(WebCore::isPublicSuffix):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (232267 => 232268)


--- trunk/Source/WebCore/ChangeLog	2018-05-29 18:24:52 UTC (rev 232267)
+++ trunk/Source/WebCore/ChangeLog	2018-05-29 18:32:00 UTC (rev 232268)
@@ -1,3 +1,18 @@
+2018-05-29  Chris Dumez  <cdu...@apple.com>
+
+        Avoid unnecessary String allocation in isPublicSuffix(const String&)
+        https://bugs.webkit.org/show_bug.cgi?id=186054
+
+        Reviewed by Sam Weinig.
+
+        Avoid unnecessary String allocation in isPublicSuffix(const String&) by calling directly
+        the decodeHostName() overload taking in a NSString*. This overload returns a NSString*,
+        which is what we need. We would previously call the overloading taking in a String, which
+        would return a String, which we would have to convert back to a NSString*.
+
+        * platform/mac/PublicSuffixMac.mm:
+        (WebCore::isPublicSuffix):
+
 2018-05-29  Alex Christensen  <achristen...@webkit.org>
 
         Do even fewer allocations in URL host operations

Modified: trunk/Source/WebCore/platform/mac/PublicSuffixMac.mm (232267 => 232268)


--- trunk/Source/WebCore/platform/mac/PublicSuffixMac.mm	2018-05-29 18:24:52 UTC (rev 232267)
+++ trunk/Source/WebCore/platform/mac/PublicSuffixMac.mm	2018-05-29 18:32:00 UTC (rev 232268)
@@ -36,7 +36,8 @@
 
 bool isPublicSuffix(const String& domain)
 {
-    NSString *host = decodeHostName(domain);
+    // Explicitly cast the domain to a NSString before calling decodeHostName() so we get a NSString back instead of a String.
+    NSString *host = decodeHostName((NSString *)domain);
     return host && _CFHostIsDomainTopLevel((CFStringRef)host);
 }
 
@@ -62,7 +63,7 @@
 
 String decodeHostName(const String& domain)
 {
-    return decodeHostName(static_cast<NSString*>(domain));
+    return decodeHostName((NSString *)(domain));
 }
 
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to