summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-09-24 01:32:19 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:52:47 -0500
commitb2cd6300d7a575ea01758233ab42b3bf205d20e1 (patch)
tree54f65131d019b42dedb59d4cd2717c36d03d9266
parent8875124a61c63d2def8ec193a98732f6fcfaa6a1 (diff)
downloadsamba-b2cd6300d7a575ea01758233ab42b3bf205d20e1.tar.gz
samba-b2cd6300d7a575ea01758233ab42b3bf205d20e1.tar.bz2
samba-b2cd6300d7a575ea01758233ab42b3bf205d20e1.zip
r2578: Pick up optimisation from Samba4 - thanks tridge !
- I recently found out that charaters below 0x3F are guaranteed not to occur as secondary bytes in any multi-byte character set. This allows for a very simple optimisation in strchr_m() and strrchr_m(). It might be a good idea to pick this up for Samba3. Jeremy. (This used to be commit 0465e2d23d27e535bad4652037b37041049bfa96)
-rw-r--r--source3/lib/util_str.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index 65a616ad41..2c0cae1d73 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -1208,6 +1208,12 @@ char *strchr_m(const char *src, char c)
smb_ucs2_t *p;
const char *s;
+ /* characters below 0x3F are guaranteed to not appear in
+ non-initial position in multi-byte charsets */
+ if ((c & 0xC0) == 0) {
+ return strchr(s, c);
+ }
+
/* 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
@@ -1237,6 +1243,12 @@ char *strchr_m(const char *src, char c)
char *strrchr_m(const char *s, char c)
{
+ /* characters below 0x3F are guaranteed to not appear in
+ non-initial position in multi-byte charsets */
+ if ((c & 0xC0) == 0) {
+ return strrchr(s, c);
+ }
+
/* 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