apr_array_copy() makes a new array, fills it with null bytes,
and then overwrites it with a copy of the source array.
This patch optimizes away the zero-fill of the part of the
array that's about to be overwritten.
--Brian
Index: srclib/apr/tables/apr_tables.c
===================================================================
RCS file: /home/cvspublic/apr/tables/apr_tables.c,v
retrieving revision 1.19
diff -u -r1.19 apr_tables.c
--- srclib/apr/tables/apr_tables.c 2001/11/26 23:17:09 1.19
+++ srclib/apr/tables/apr_tables.c 2001/12/02 03:56:52
@@ -167,10 +167,14 @@
APR_DECLARE(apr_array_header_t *) apr_array_copy(apr_pool_t *p,
const apr_array_header_t *arr)
{
- apr_array_header_t *res = apr_array_make(p, arr->nalloc, arr->elt_size);
+ apr_array_header_t *res =
+ (apr_array_header_t *) apr_palloc(p, sizeof(apr_array_header_t));
+ make_array_core(res, p, arr->nalloc, arr->elt_size, 0);
memcpy(res->elts, arr->elts, arr->elt_size * arr->nelts);
res->nelts = arr->nelts;
+ memset(res->elts + res->elt_size * res->nelts, 0,
+ res->elt_size * (res->nalloc - res->nelts));
return res;
}