Title: [174993] trunk/Source/WebCore
- Revision
- 174993
- Author
- [email protected]
- Date
- 2014-10-21 12:41:47 -0700 (Tue, 21 Oct 2014)
Log Message
[Curl] Optimization; avoid string reallocation.
https://bugs.webkit.org/show_bug.cgi?id=137920
Patch by [email protected] <[email protected]> on 2014-10-21
Reviewed by Brent Fulgham.
Profiling reveals that the cookiesForDOM function is spending time on removing a character from a string.
* platform/network/curl/CookieJarCurl.cpp:
(WebCore::domainMatch):
(WebCore::addMatchingCurlCookie):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (174992 => 174993)
--- trunk/Source/WebCore/ChangeLog 2014-10-21 18:44:20 UTC (rev 174992)
+++ trunk/Source/WebCore/ChangeLog 2014-10-21 19:41:47 UTC (rev 174993)
@@ -1,3 +1,16 @@
+2014-10-21 [email protected] <[email protected]>
+
+ [Curl] Optimization; avoid string reallocation.
+ https://bugs.webkit.org/show_bug.cgi?id=137920
+
+ Reviewed by Brent Fulgham.
+
+ Profiling reveals that the cookiesForDOM function is spending time on removing a character from a string.
+
+ * platform/network/curl/CookieJarCurl.cpp:
+ (WebCore::domainMatch):
+ (WebCore::addMatchingCurlCookie):
+
2014-10-21 Joanmarie Diggs <[email protected]>
AX: [ATK] CSS-generated text content not exposed to assistive technologies
Modified: trunk/Source/WebCore/platform/network/curl/CookieJarCurl.cpp (174992 => 174993)
--- trunk/Source/WebCore/platform/network/curl/CookieJarCurl.cpp 2014-10-21 18:44:20 UTC (rev 174992)
+++ trunk/Source/WebCore/platform/network/curl/CookieJarCurl.cpp 2014-10-21 19:41:47 UTC (rev 174993)
@@ -43,6 +43,29 @@
cookie++;
}
+static bool domainMatch(const String& cookieDomain, const String& host)
+{
+ size_t index = host.find(cookieDomain);
+
+ bool tailMatch = (index != WTF::notFound && index + cookieDomain.length() == host.length());
+
+ // Check if host equals cookie domain.
+ if (tailMatch && !index)
+ return true;
+
+ // Check if host is a subdomain of the domain in the cookie.
+ // Curl uses a '.' in front of domains to indicate it's valid on subdomains.
+ if (tailMatch && index > 0 && host[index] == '.')
+ return true;
+
+ // Check the special case where host equals the cookie domain, except for a leading '.' in the cookie domain.
+ // E.g. cookie domain is .apple.com and host is apple.com.
+ if (cookieDomain[0] == '.' && cookieDomain.find(host) == 1)
+ return true;
+
+ return false;
+}
+
static void addMatchingCurlCookie(const char* cookie, const String& domain, const String& path, StringBuilder& cookies, bool httponly)
{
// Check if the cookie matches domain and path, and is not expired.
@@ -80,18 +103,7 @@
return;
}
-
- if (cookieDomain[0] == '.') {
- // Check if domain is a subdomain of the domain in the cookie.
- // Curl uses a '.' in front of domains to indicate its valid on subdomains.
- cookieDomain.remove(0);
- int lenDiff = domain.length() - cookieDomain.length();
- int index = domain.find(cookieDomain);
- if (index == lenDiff)
- subDomain = true;
- }
-
- if (!subDomain && cookieDomain != domain)
+ if (!domainMatch(cookieDomain, domain))
return;
String strBoolean;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes