libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit edb98b9a34d404f9c22aa40628319c4b53865b84
parent 5a5e402b11c2b696f3f49665af2e30eb4bc056c3
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Fri, 30 Apr 2021 17:01:42 +0300

mhd_str: minor optimization

Diffstat:
Msrc/microhttpd/mhd_str.c | 29+++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/src/microhttpd/mhd_str.c b/src/microhttpd/mhd_str.c @@ -350,11 +350,16 @@ MHD_str_equal_caseless_ (const char *str1, { const char c1 = *str1; const char c2 = *str2; - if ( (c1 != c2) && - (toasciilower (c1) != toasciilower (c2)) ) + if ( (c1 == c2) || + (isasciiupper (c1) ? + ((c1 - 'A' + 'a') == c2) : + (isasciiupper (c2) && (c1 == (c2 - 'A' + 'a')))) ) + { + str1++; + str2++; + } + else return 0; - str1++; - str2++; } return 0 == (*str2); } @@ -387,8 +392,12 @@ MHD_str_equal_caseless_n_ (const char *const str1, const char c2 = str2[i]; if (0 == c2) return 0 == c1; - if ( (c1 != c2) && - (toasciilower (c1) != toasciilower (c2)) ) + if ( (c1 == c2) || + (isasciiupper (c1) ? + ((c1 - 'A' + 'a') == c2) : + (isasciiupper (c2) && (c1 == (c2 - 'A' + 'a')))) ) + continue; + else return 0; } return ! 0; @@ -415,8 +424,12 @@ MHD_str_equal_caseless_bin_n_ (const char *const str1, { const char c1 = str1[i]; const char c2 = str2[i]; - if ( (c1 != c2) && - (toasciilower (c1) != toasciilower (c2)) ) + if ( (c1 == c2) || + (isasciiupper (c1) ? + ((c1 - 'A' + 'a') == c2) : + (isasciiupper (c2) && (c1 == (c2 - 'A' + 'a')))) ) + continue; + else return 0; } return ! 0;