Chromium Code Reviews| Index: net/base/registry_controlled_domains/registry_controlled_domain.cc |
| diff --git a/net/base/registry_controlled_domains/registry_controlled_domain.cc b/net/base/registry_controlled_domains/registry_controlled_domain.cc |
| index 493ea68678b0b2a11d1817f42eefa33328894dc2..e1e24907a08cd080baa29781279d32c166a56ebb 100644 |
| --- a/net/base/registry_controlled_domains/registry_controlled_domain.cc |
| +++ b/net/base/registry_controlled_domains/registry_controlled_domain.cc |
| @@ -329,6 +329,15 @@ bool SameDomainOrHost( |
| const GURL& gurl1, |
| const GURL& gurl2, |
| PrivateRegistryFilter filter) { |
| + // First, check if the hosts are identical. |
| + const url::Component host1 = gurl1.parsed_for_possibly_invalid_spec().host; |
| + const url::Component host2 = gurl2.parsed_for_possibly_invalid_spec().host; |
| + if ((host1.len > 0) && (host1.len == host2.len) && |
| + !strncmp(gurl1.possibly_invalid_spec().data() + host1.begin, |
| + gurl2.possibly_invalid_spec().data() + host2.begin, host1.len)) { |
| + return true; |
| + } |
| + |
| // See if both URLs have a known domain + registry, and those values are the |
| // same. |
| const base::StringPiece domain1 = |
| @@ -337,15 +346,7 @@ bool SameDomainOrHost( |
| GetDomainAndRegistryAsStringPiece(gurl2, filter); |
| if (!domain1.empty() || !domain2.empty()) |
| return domain1 == domain2; |
| - |
| - // No domains. See if the hosts are identical. |
| - const url::Component host1 = gurl1.parsed_for_possibly_invalid_spec().host; |
| - const url::Component host2 = gurl2.parsed_for_possibly_invalid_spec().host; |
| - if ((host1.len <= 0) || (host1.len != host2.len)) |
| - return false; |
| - return !strncmp(gurl1.possibly_invalid_spec().data() + host1.begin, |
| - gurl2.possibly_invalid_spec().data() + host2.begin, |
| - host1.len); |
| + return false; |
|
Peter Kasting
2016/11/14 23:00:25
I think a slightly faster, and hopefully more read
|
| } |
| bool SameDomainOrHost(const url::Origin& origin1, |