]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
lib: better optimized casecompare() and ncasecompare()
authorSergey <sergionso@gmail.com>
Thu, 13 Feb 2025 01:14:08 +0000 (17:14 -0800)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 13 Feb 2025 10:14:52 +0000 (11:14 +0100)
Less 'jne` or `je` CPU instructions.

Closes #16311

lib/strcase.c

index 112aedb1930059e7748df7e5cd277c0d8bac9d78..7ae0929af3bfc324bf0c2a2a01fd019dd8b822ae 100644 (file)
@@ -91,7 +91,7 @@ char Curl_raw_tolower(char in)
 
 static int casecompare(const char *first, const char *second)
 {
-  while(*first && *second) {
+  while(*first) {
     if(Curl_raw_toupper(*first) != Curl_raw_toupper(*second))
       /* get out of the loop as soon as they do not match */
       return 0;
@@ -118,7 +118,7 @@ int curl_strequal(const char *first, const char *second)
 
 static int ncasecompare(const char *first, const char *second, size_t max)
 {
-  while(*first && *second && max) {
+  while(*first && max) {
     if(Curl_raw_toupper(*first) != Curl_raw_toupper(*second))
       return 0;
     max--;