From 0097921f4253cf8e89731cbd055ae72bc1b80305 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 30 May 2022 21:55:05 -0500 Subject: [PATCH] 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. --- libtransmission/web-utils.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libtransmission/web-utils.cc b/libtransmission/web-utils.cc index a51f03ab8..7e25883fe 100644 --- a/libtransmission/web-utils.cc +++ b/libtransmission/web-utils.cc @@ -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) {