[SCM] Samba Shared Repository - branch v3-2-test updated - initial-v3-2-unstable-1241-g329b924

Jeremy Allison jra at samba.org
Thu Jan 10 01:33:05 GMT 2008


The branch, v3-2-test has been updated
       via  329b924cba8225002ca40db26c45b31d141a0925 (commit)
      from  bc932b8ad4396f76b71c43efe9a6346f89c3632c (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit 329b924cba8225002ca40db26c45b31d141a0925
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Jan 9 17:32:26 2008 -0800

    Fixup hot paths - add macro for toupper (c < 0x80).
    This now matches 3.0.x on my micro-tests.
    Jeremy.

-----------------------------------------------------------------------

Summary of changes:
 source/include/smb_macros.h |    8 ++++++++
 source/lib/charcnv.c        |   18 ++++++++++++------
 source/lib/util_str.c       |   21 ++++++++++++++++-----
 3 files changed, 36 insertions(+), 11 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/include/smb_macros.h b/source/include/smb_macros.h
index 3324f3f..463a2bd 100644
--- a/source/include/smb_macros.h
+++ b/source/include/smb_macros.h
@@ -385,4 +385,12 @@ do { \
 #define ISDOTDOT(p) (*(p) == '.' && *((p) + 1) == '.' && *((p) + 2) == '\0')
 #endif /* ISDOTDOT */
 
+#ifndef toupper_ascii_fast
+/* Warning - this must only be called with 0 <= c < 128. IT WILL
+ * GIVE GARBAGE if c > 128 or c < 0. JRA.
+ */
+extern char toupper_ascii_fast_table[];
+#define toupper_ascii_fast(c) toupper_ascii_fast_table[(unsigned int)(c)];
+#endif
+
 #endif /* _SMB_MACROS_H */
diff --git a/source/lib/charcnv.c b/source/lib/charcnv.c
index 8a00b23..eeff805 100644
--- a/source/lib/charcnv.c
+++ b/source/lib/charcnv.c
@@ -614,10 +614,16 @@ size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
   out:
 
 	destlen = destlen - o_len;
-	if (ctx) {
-		ob = (char *)TALLOC_REALLOC(ctx,ob,destlen);
-	} else {
-		ob = (char *)SMB_REALLOC(ob,destlen);
+	/* Don't shrink unless we're reclaiming a lot of
+	 * space. This is in the hot codepath and these
+	 * reallocs *cost*. JRA.
+	 */
+	if (o_len > 1024) {
+		if (ctx) {
+			ob = (char *)TALLOC_REALLOC(ctx,ob,destlen);
+		} else {
+			ob = (char *)SMB_REALLOC(ob,destlen);
+		}
 	}
 
 	if (destlen && !ob) {
@@ -778,7 +784,7 @@ char *strdup_upper(const char *s)
 	while (*p) {
 		if (*p & 0x80)
 			break;
-		*q++ = toupper_ascii(*p);
+		*q++ = toupper_ascii_fast(*p);
 		p++;
 	}
 
@@ -844,7 +850,7 @@ char *talloc_strdup_upper(TALLOC_CTX *ctx, const char *s)
 	while (*p) {
 		if (*p & 0x80)
 			break;
-		*q++ = toupper_ascii(*p);
+		*q++ = toupper_ascii_fast(*p);
 		p++;
 	}
 
diff --git a/source/lib/util_str.c b/source/lib/util_str.c
index 7e21fe1..3e32681 100644
--- a/source/lib/util_str.c
+++ b/source/lib/util_str.c
@@ -24,6 +24,17 @@
 
 #include "includes.h"
 
+char toupper_ascii_fast_table[128] = {
+	0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf,
+	0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+	0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+	0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+	0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+	0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+	0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+	0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f
+};
+
 /**
  * @file
  * @brief String utilities.
@@ -187,8 +198,8 @@ int StrCaseCmp(const char *s, const char *t)
 			 * from here on in */
 			break;
 
-		us = toupper_ascii(*ps);
-		ut = toupper_ascii(*pt);
+		us = toupper_ascii_fast(*ps);
+		ut = toupper_ascii_fast(*pt);
 		if (us == ut)
 			continue;
 		else if (us < ut)
@@ -246,8 +257,8 @@ int StrnCaseCmp(const char *s, const char *t, size_t len)
 			 * hard way from here on in */
 			break;
 
-		us = toupper_ascii(*ps);
-		ut = toupper_ascii(*pt);
+		us = toupper_ascii_fast(*ps);
+		ut = toupper_ascii_fast(*pt);
 		if (us == ut)
 			continue;
 		else if (us < ut)
@@ -1679,7 +1690,7 @@ void strupper_m(char *s)
 	   (ie. they match for the first 128 chars) */
 
 	while (*s && !(((unsigned char)s[0]) & 0x80)) {
-		*s = toupper_ascii((unsigned char)*s);
+		*s = toupper_ascii_fast((unsigned char)*s);
 		s++;
 	}
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list