From: Miod Vallat Date: Wed, 25 Jun 2025 17:07:07 +0000 (+0200) Subject: Use twice as fewer dns_tolower() calls in pdns_ilexicographical_compare(). X-Git-Tag: rec-5.3.0-alpha2~40^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69bc7acda72bc6bf93dcb66ca7b2d960f72fdc8c;p=thirdparty%2Fpdns.git Use twice as fewer dns_tolower() calls in pdns_ilexicographical_compare(). [Although the compiler had probably been smart enough to optimize this already] Signed-off-by: Miod Vallat --- diff --git a/pdns/misc.hh b/pdns/misc.hh index 0b2d088383..710adaa909 100644 --- a/pdns/misc.hh +++ b/pdns/misc.hh @@ -385,8 +385,11 @@ inline bool pdns_ilexicographical_compare(const std::string& a, const std::strin const unsigned char *aPtr = (const unsigned char*)a.c_str(), *bPtr = (const unsigned char*)b.c_str(); const unsigned char *aEptr = aPtr + a.length(), *bEptr = bPtr + b.length(); while(aPtr != aEptr && bPtr != bEptr) { - if ((*aPtr != *bPtr) && (dns_tolower(*aPtr) - dns_tolower(*bPtr))) - return (dns_tolower(*aPtr) - dns_tolower(*bPtr)) < 0; + if (*aPtr != *bPtr) { + if (int rc = dns_tolower(*aPtr) - dns_tolower(*bPtr); rc != 0) { + return rc < 0; + } + } aPtr++; bPtr++; }