From 08c3907f4eb9a6235ff401e39b949dbcc929a7ee Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 4 Sep 2003 23:26:13 +0000 Subject: Fastpath strchr_m for ASCII. Jeremy. (This used to be commit b3176f2ec246441dd483dc9757a487535b1656e6) --- source3/lib/util_str.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index e1db93a131..34fdf75f63 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -1110,6 +1110,19 @@ char *strchr_m(const char *s, char c) pstring s2; smb_ucs2_t *p; + /* this is quite a common operation, so we want it to be + fast. We optimise for the ascii case, knowing that all our + supported multi-byte character sets are ascii-compatible + (ie. they match for the first 128 chars) */ + + while (*s && !(((unsigned char)s[0]) & 0x7F)) { + if (*s == c) + return s; + } + + if (!*s) + return NULL; + push_ucs2(NULL, ws, s, sizeof(ws), STR_TERMINATE); p = strchr_w(ws, UCS2_CHAR(c)); if (!p) -- cgit