apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject cvs commit: apr/file_io/unix filepath.c
Date Sun, 17 Mar 2002 03:24:15 GMT
brianp      02/03/16 19:24:15

  Modified:    file_io/unix filepath.c
  Log:
  Performance improvement for apr_filepath_merge()
  
  Revision  Changes    Path
  1.14      +13 -10    apr/file_io/unix/filepath.c
  
  Index: filepath.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/unix/filepath.c,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- filepath.c	17 Mar 2002 03:02:32 -0000	1.13
  +++ filepath.c	17 Mar 2002 03:24:15 -0000	1.14
  @@ -234,10 +234,11 @@
       {
           /* Parse each segment, find the closing '/' 
            */
  -        seglen = 0;
  -        while (addpath[seglen] && addpath[seglen] != '/') {
  -            ++seglen;
  +        const char *next = addpath;
  +        while (*next && (*next != '/')) {
  +            ++next;
           }
  +        seglen = next - addpath;
   
           if (seglen == 0 || (seglen == 1 && addpath[0] == '.')) {
               /* noop segment (/ or ./) so skip it 
  @@ -300,21 +301,23 @@
           {
               /* An actual segment, append it to the destination path
                */
  -            apr_size_t i = (addpath[seglen] != '\0');
  -            if (pathlen + seglen + i >= maxlen) {
  +            if (*next) {
  +                seglen++;
  +            }
  +            if (pathlen + seglen >= maxlen) {
                   return APR_ENAMETOOLONG;
               }
  -            memcpy(path + pathlen, addpath, seglen + i);
  -            pathlen += seglen + i;
  +            memcpy(path + pathlen, addpath, seglen);
  +            pathlen += seglen;
           }
   
           /* Skip over trailing slash to the next segment
            */
  -        if (addpath[seglen]) {
  -            ++seglen;
  +        if (*next) {
  +            ++next;
           }
   
  -        addpath += seglen;
  +        addpath = next;
       }
       path[pathlen] = '\0';
       
  
  
  

Mime
View raw message