apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dean gaudet <d...@arctic.org>
Subject Re: apr_strcat optimization(s)
Date Tue, 17 Jul 2001 23:59:56 GMT
you might as well memcpy() if you're going to strlen() first.  it's less
complex inline code.

-dean

On Tue, 19 Jun 2001, Doug MacEachern wrote:

> 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