mirror of
https://github.com/samba-team/samba.git
synced 2024-12-25 23:21:54 +03:00
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 commit is contained in:
parent
fc51c97ea8
commit
0465e2d23d
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user