apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Stoddard" <b...@wstoddard.com>
Subject Re: apr_strcat optimization(s)
Date Tue, 19 Jun 2001 17:54:25 GMT
+1
----- Original Message ----- 
From: "Doug MacEachern" <dougm@covalent.net>
To: <dev@apr.apache.org>
Sent: Tuesday, June 19, 2001 1:17 PM
Subject: apr_strcat optimization(s)


> the current apr_strcat does strlen() twice for each argument, this patch
> makes it happen just once.  it would also be handy to have an apr_pstrcatn
> (name debatable) that returns the calculated length so the caller can
> avoid another strlen(), something like:
> 
> apr_size_t total_len;
> apr_status_t status = apr_pstrcatn(pool, &total_len, ..., NULL);
> 
> then apr_pstrcat() would just be a wrapper around apr_pstrcatn().
> i'll get a patch together if the name/prototype is agreed on.
> 
> --- srclib/apr/strings/apr_strings.c    2001/05/10 18:05:18     1.13
> +++ srclib/apr/strings/apr_strings.c    2001/06/19 17:12:01
> @@ -137,8 +137,9 @@
>      va_start(adummy, a);
>  
>      while ((argp = va_arg(adummy, char *)) != NULL) {
> -        strcpy(cp, argp);
> -        cp += strlen(argp);
> +        len = strlen(argp);
> +        strncpy(cp, argp, len);
> +        cp += len;
>      }
>  
>      va_end(adummy);
> 
> 


Mime
View raw message