From: Douglas Bagnall Date: Tue, 14 May 2024 09:33:16 +0000 (+1200) Subject: util:charset: strncasecmp_ldb avoids iconv for ASCII X-Git-Tag: tdb-1.4.11~562 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f9797950fd69c16dfab39804dc53172977a345ee;p=thirdparty%2Fsamba.git util:charset: strncasecmp_ldb avoids iconv for ASCII This is a common case, and we can save a bit of work. Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/lib/util/charset/util_unistr.c b/lib/util/charset/util_unistr.c index fa3b0f2a7a0..c042bead4ed 100644 --- a/lib/util/charset/util_unistr.c +++ b/lib/util/charset/util_unistr.c @@ -250,6 +250,10 @@ _PUBLIC_ int strncasecmp_ldb(const char *s1, } else if (*s1 == ' ') { EAT_SPACE(s1, len1, ends_in_space1); c1 = ends_in_space1 ? 0 : ' '; + } else if ((*s1 & 0x80) == 0) { + c1 = *s1; + s1++; + len1--; } else { c1 = next_codepoint_handle_ext(iconv_handle, s1, len1, CH_UNIX, &cs1); @@ -264,6 +268,10 @@ _PUBLIC_ int strncasecmp_ldb(const char *s1, } else if (*s2 == ' ') { EAT_SPACE(s2, len2, ends_in_space2); c2 = ends_in_space2 ? 0 : ' '; + } else if ((*s2 & 0x80) == 0) { + c2 = *s2; + s2++; + len2--; } else { c2 = next_codepoint_handle_ext(iconv_handle, s2, len2, CH_UNIX, &cs2);