More cachegrind tuning, plus fix an error message.
authorJeremy Allison <jra@samba.org>
Fri, 5 Sep 2003 21:30:50 +0000 (21:30 +0000)
committerJeremy Allison <jra@samba.org>
Fri, 5 Sep 2003 21:30:50 +0000 (21:30 +0000)
Jeremy.
(This used to be commit 8cb9ec5d533085d40fc6bfe4ca9647d80bf41ac7)

source3/lib/charcnv.c
source3/smbd/statcache.c
source3/smbd/trans2.c

index ceb9d57fc71a92d5d854227c2dd05b20e4ce7501..5a922e226ce2061e4a9bb9337100f0332ff5b5b5 100644 (file)
@@ -511,22 +511,43 @@ size_t unix_strupper(const char *src, size_t srclen, char *dest, size_t destlen)
 
 char *strdup_upper(const char *s)
 {
-       size_t size;
-       wpstring buffer;
        pstring out_buffer;
-       
-       size = convert_string(CH_UNIX, CH_UCS2, s, -1, buffer, sizeof(buffer));
-       if (size == -1) {
-               return NULL;
+       const unsigned char *p = (const unsigned char *)s;
+       unsigned char *q = (unsigned char *)out_buffer;
+
+       /* 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
+          (ie. they match for the first 128 chars) */
+
+       while (1) {
+               if (*p & 0x80)
+                       break;
+               *q++ = toupper(*p);
+               if (!*p)
+                       break;
+               p++;
+               if (p - ( const unsigned char *)s >= sizeof(pstring))
+                       break;
        }
 
-       strupper_w(buffer);
+       if (*p) {
+               /* MB case. */
+               size_t size;
+               wpstring buffer;
+               size = convert_string(CH_UNIX, CH_UCS2, s, -1, buffer, sizeof(buffer));
+               if (size == -1) {
+                       return NULL;
+               }
+
+               strupper_w(buffer);
        
-       size = convert_string(CH_UCS2, CH_UNIX, buffer, sizeof(buffer), out_buffer, sizeof(out_buffer));
-       if (size == -1) {
-               return NULL;
+               size = convert_string(CH_UCS2, CH_UNIX, buffer, sizeof(buffer), out_buffer, sizeof(out_buffer));
+               if (size == -1) {
+                       return NULL;
+               }
        }
-       
+
        return strdup(out_buffer);
 }
 
index 28915a30a081972fd918f1a7379812e4432a1398..948173687d9ebcb9516a738ab1a4210bb04ea164 100644 (file)
@@ -217,10 +217,10 @@ BOOL stat_cache_lookup(connection_struct *conn, pstring name, pstring dirpath,
        /*
         * Don't lookup trivial valid directory entries.
         */
-       if((*name == '\0') || (strcmp(name, ".") == 0) || (strcmp(name, "..") == 0)) {
-               DO_PROFILE_INC(statcache_misses);
+       if((*name == '\0') || (name[0] == '.' && 
+                               ((name[1] == '\0') ||
+                                (name[1] == '.' && name[1] == '\0'))))
                return False;
-       }
 
        if (case_sensitive) {
                chk_name = strdup(name);
@@ -248,6 +248,7 @@ BOOL stat_cache_lookup(connection_struct *conn, pstring name, pstring dirpath,
        while (1) {
                hash_elem = hash_lookup(&stat_cache, chk_name);
                if(hash_elem == NULL) {
+                       DEBUG(10,("stat_cache_lookup: lookup failed for name [%s]\n", chk_name ));
                        /*
                         * Didn't find it - remove last component for next try.
                         */
@@ -277,6 +278,7 @@ BOOL stat_cache_lookup(connection_struct *conn, pstring name, pstring dirpath,
                        }
                } else {
                        scp = (stat_cache_entry *)(hash_elem->value);
+                       DEBUG(10,("stat_cache_lookup: lookup succeeded for name [%s] -> [%s]\n", chk_name, scp->translated_path ));
                        DO_PROFILE_INC(statcache_hits);
                        if(SMB_VFS_STAT(conn,scp->translated_path, pst) != 0) {
                                /* Discard this entry - it doesn't exist in the filesystem.  */
index 7e46a6b6ab22cd2e7851967b558555c3df35fe30..033e76a33e1dcb9a664bbc6961c1d5852f11e6a4 100644 (file)
@@ -1781,7 +1781,7 @@ static int call_trans2setfsinfo(connection_struct *conn,
 
 int set_bad_path_error(int err, BOOL bad_path, char *outbuf, int def_class, uint32 def_code)
 {
-       DEBUG(10,("set_bad_path_error: err = %dm bad_path = %d\n",
+       DEBUG(10,("set_bad_path_error: err = %d bad_path = %d\n",
                        err, (int)bad_path ));
 
        if(err == ENOENT) {