svn commit: samba r2578 - in branches/SAMBA_3_0/source/lib: .
jra at samba.org
jra at samba.org
Fri Sep 24 01:32:19 GMT 2004
Author: jra
Date: 2004-09-24 01:32:19 +0000 (Fri, 24 Sep 2004)
New Revision: 2578
WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_3_0/source/lib&rev=2578&nolog=1
Log:
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.
Modified:
branches/SAMBA_3_0/source/lib/util_str.c
Changeset:
Modified: branches/SAMBA_3_0/source/lib/util_str.c
===================================================================
--- branches/SAMBA_3_0/source/lib/util_str.c 2004-09-24 01:21:21 UTC (rev 2577)
+++ branches/SAMBA_3_0/source/lib/util_str.c 2004-09-24 01:32:19 UTC (rev 2578)
@@ -1208,6 +1208,12 @@
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 *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
More information about the samba-cvs
mailing list