perf: avoid some unnecessary psl domain strdups (#3160)

We were incorrectly duplicating most domains because the "do we need
to convert before feeding to psl" test incorrectly returned true for
many domains.
This commit is contained in:
Charles Kerr 2022-05-30 21:55:05 -05:00 committed by GitHub
parent 1fc0e5d0d8
commit 0097921f42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -252,12 +252,12 @@ bool tr_isValidTrackerScheme(std::string_view scheme)
return std::find(std::begin(Schemes), std::end(Schemes), scheme) != std::end(Schemes);
}
bool isAsciiLowerCase(std::string_view host)
bool isAsciiNonUpperCase(std::string_view host)
{
return std::all_of(
std::begin(host),
std::end(host),
[](unsigned char ch) { return (ch < 128) && (std::islower(ch) != 0); });
[](unsigned char ch) { return (ch < 128) && (std::isupper(ch) == 0); });
}
// www.example.com -> example
@ -282,7 +282,7 @@ std::string_view getSiteName(std::string_view host)
}
// is it a registered name?
if (isAsciiLowerCase(host))
if (isAsciiNonUpperCase(host))
{
if (char const* const top = psl_registrable_domain(psl_builtin(), std::data(szhost)); top != nullptr)
{