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:
parent
1fc0e5d0d8
commit
0097921f42
|
@ -252,12 +252,12 @@ bool tr_isValidTrackerScheme(std::string_view scheme)
|
||||||
return std::find(std::begin(Schemes), std::end(Schemes), scheme) != std::end(Schemes);
|
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(
|
return std::all_of(
|
||||||
std::begin(host),
|
std::begin(host),
|
||||||
std::end(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
|
// www.example.com -> example
|
||||||
|
@ -282,7 +282,7 @@ std::string_view getSiteName(std::string_view host)
|
||||||
}
|
}
|
||||||
|
|
||||||
// is it a registered name?
|
// 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)
|
if (char const* const top = psl_registrable_domain(psl_builtin(), std::data(szhost)); top != nullptr)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue