Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Unified Diff: components/google/core/browser/google_util.cc

Issue 2495773003: Fast path for google_util::IsValidHostName (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/google/core/browser/google_util.cc
diff --git a/components/google/core/browser/google_util.cc b/components/google/core/browser/google_util.cc
index a6654c9f28701ad6a10781ed527a4b6f12e486db..f3e8fd432b8e35afac9835c7e8727b6ff0ac2f27 100644
--- a/components/google/core/browser/google_util.cc
+++ b/components/google/core/browser/google_util.cc
@@ -50,6 +50,9 @@ bool IsPathHomePageBase(base::StringPiece path) {
bool IsValidHostName(base::StringPiece host,
base::StringPiece domain_in_lower_case,
SubdomainPermission subdomain_permission) {
+ // Fast path to avoid searching the registry set.
+ if (host.find(domain_in_lower_case) == base::StringPiece::npos)
+ return false;
size_t tld_length =
net::registry_controlled_domains::GetCanonicalHostRegistryLength(
host, net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698