svn commit: samba r2579 - in trunk/source/lib: .

jra at samba.org jra at samba.org
Fri Sep 24 01:32:24 GMT 2004


Author: jra
Date: 2004-09-24 01:32:24 +0000 (Fri, 24 Sep 2004)
New Revision: 2579

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/trunk/source/lib&rev=2579&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:
   trunk/source/lib/util_str.c


Changeset:
Modified: trunk/source/lib/util_str.c
===================================================================
--- trunk/source/lib/util_str.c	2004-09-24 01:32:19 UTC (rev 2578)
+++ trunk/source/lib/util_str.c	2004-09-24 01:32:24 UTC (rev 2579)
@@ -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