diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-04-30 17:01:42 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-04-30 17:01:42 +0300 |
commit | edb98b9a34d404f9c22aa40628319c4b53865b84 (patch) | |
tree | 2d4dbf9b369ebe7d2ee6a5e3d868e1edc95f65cf | |
parent | 5a5e402b11c2b696f3f49665af2e30eb4bc056c3 (diff) | |
download | libmicrohttpd-edb98b9a34d404f9c22aa40628319c4b53865b84.tar.gz libmicrohttpd-edb98b9a34d404f9c22aa40628319c4b53865b84.zip |
mhd_str: minor optimization
-rw-r--r-- | src/microhttpd/mhd_str.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/microhttpd/mhd_str.c b/src/microhttpd/mhd_str.c index 08162fb2..c0218bca 100644 --- a/src/microhttpd/mhd_str.c +++ b/src/microhttpd/mhd_str.c | |||
@@ -350,11 +350,16 @@ MHD_str_equal_caseless_ (const char *str1, | |||
350 | { | 350 | { |
351 | const char c1 = *str1; | 351 | const char c1 = *str1; |
352 | const char c2 = *str2; | 352 | const char c2 = *str2; |
353 | if ( (c1 != c2) && | 353 | if ( (c1 == c2) || |
354 | (toasciilower (c1) != toasciilower (c2)) ) | 354 | (isasciiupper (c1) ? |
355 | ((c1 - 'A' + 'a') == c2) : | ||
356 | (isasciiupper (c2) && (c1 == (c2 - 'A' + 'a')))) ) | ||
357 | { | ||
358 | str1++; | ||
359 | str2++; | ||
360 | } | ||
361 | else | ||
355 | return 0; | 362 | return 0; |
356 | str1++; | ||
357 | str2++; | ||
358 | } | 363 | } |
359 | return 0 == (*str2); | 364 | return 0 == (*str2); |
360 | } | 365 | } |
@@ -387,8 +392,12 @@ MHD_str_equal_caseless_n_ (const char *const str1, | |||
387 | const char c2 = str2[i]; | 392 | const char c2 = str2[i]; |
388 | if (0 == c2) | 393 | if (0 == c2) |
389 | return 0 == c1; | 394 | return 0 == c1; |
390 | if ( (c1 != c2) && | 395 | if ( (c1 == c2) || |
391 | (toasciilower (c1) != toasciilower (c2)) ) | 396 | (isasciiupper (c1) ? |
397 | ((c1 - 'A' + 'a') == c2) : | ||
398 | (isasciiupper (c2) && (c1 == (c2 - 'A' + 'a')))) ) | ||
399 | continue; | ||
400 | else | ||
392 | return 0; | 401 | return 0; |
393 | } | 402 | } |
394 | return ! 0; | 403 | return ! 0; |
@@ -415,8 +424,12 @@ MHD_str_equal_caseless_bin_n_ (const char *const str1, | |||
415 | { | 424 | { |
416 | const char c1 = str1[i]; | 425 | const char c1 = str1[i]; |
417 | const char c2 = str2[i]; | 426 | const char c2 = str2[i]; |
418 | if ( (c1 != c2) && | 427 | if ( (c1 == c2) || |
419 | (toasciilower (c1) != toasciilower (c2)) ) | 428 | (isasciiupper (c1) ? |
429 | ((c1 - 'A' + 'a') == c2) : | ||
430 | (isasciiupper (c2) && (c1 == (c2 - 'A' + 'a')))) ) | ||
431 | continue; | ||
432 | else | ||
420 | return 0; | 433 | return 0; |
421 | } | 434 | } |
422 | return ! 0; | 435 | return ! 0; |