apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Bloom <...@covalent.net>
Subject Re: [PATCH] performance improvement for apr_pstrcat
Date Thu, 27 Sep 2001 01:56:21 GMT
On Wednesday 26 September 2001 06:34 pm, Brian Pane wrote:
> I instrumented apr_pstrcat and found that, in Apache 2.0, the number of
> strings it's asked to concatenate is 6 or less 99+% of the time.
>
> apr_pstrcat does two passes through its args: one to compute the
> length, a second to do the copying.  This patch adds a buffer to
> save the lengths of the first 6 args so that the second pass
> doesn't need to another strlen on them.  (If you pass in more than
> 6 strings to concatenate, this optimization just gets applied to the
> first 6.)
>
> --Brian

Index: srclib/apr/strings/apr_strings.c
===================================================================
RCS file: /home/cvspublic/apr/strings/apr_strings.c,v
retrieving revision 1.20
diff -u -r1.20 apr_strings.c
--- srclib/apr/strings/apr_strings.c    2001/07/26 03:11:00     1.20
+++ srclib/apr/strings/apr_strings.c    2001/09/27 01:27:06
@@ -110,6 +110,9 @@
 APR_DECLARE_NONSTD(char *) apr_pstrcat(apr_pool_t *a, ...)
 {
     char *cp, *argp, *res;
+    static const int MAX_SAVED_LENGTHS = 6;

Why is this a static const istead of a #define?

+    apr_size_t saved_lengths[MAX_SAVED_LENGTHS];
+    int nargs = 0;
 
     /* Pass one --- find length of required string */
 
Ryan

______________________________________________________________
Ryan Bloom				rbb@apache.org
Covalent Technologies			rbb@covalent.net
--------------------------------------------------------------

Mime
View raw message