diff options
author | Jeremy Allison <jra@samba.org> | 2003-09-04 23:26:13 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2003-09-04 23:26:13 +0000 |
commit | 08c3907f4eb9a6235ff401e39b949dbcc929a7ee (patch) | |
tree | 057584498eb31a00103af7f4e5a0a37800f6e559 /source3/lib | |
parent | 0e8c2a4133158b59426ec0b260e97d1dacf98e73 (diff) | |
download | samba-08c3907f4eb9a6235ff401e39b949dbcc929a7ee.tar.gz samba-08c3907f4eb9a6235ff401e39b949dbcc929a7ee.tar.bz2 samba-08c3907f4eb9a6235ff401e39b949dbcc929a7ee.zip |
Fastpath strchr_m for ASCII.
Jeremy.
(This used to be commit b3176f2ec246441dd483dc9757a487535b1656e6)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util_str.c | 13 |
1 files changed, 13 insertions, 0 deletions
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) |