Hello.

I think that currently the code that obtains inherited properties for servers
that don't support the capability uses an inefficient way of array filling.
At each iteration, all previously added properties are moved one position to
the right to maintain depth-first order. I think it's possible to provide a
similar behavior walking the array of iprop requests from the end and get rid
of extra copying of array elements.

I've attached a patch.

Regards,
Denis Kovalchuk
Fix an inefficient way to fill an array of inherited properties.

The code that obtains inherited properties for servers that don't support the
capability used an inefficient way of array filling. At each iteration, all
previously added properties were moved one position to the right to maintain
depth-first order. As a solution, walk the array of iprop requests from the end
and get rid of extra copying of array elements.

* subversion/libsvn_ra_serf/inherited_props.c
  (): Remove unused 'svn_sorts.h' and 'private/svn_sorts_private.h' includes.
  (get_iprops_via_more_requests): Walk the array of iprop requests from the
   end.

Patch by: Denis Kovalchuk <denis.kovalc...@visualsvn.com>

Index: subversion/libsvn_ra_serf/inherited_props.c
===================================================================
--- subversion/libsvn_ra_serf/inherited_props.c (revision 1877782)
+++ subversion/libsvn_ra_serf/inherited_props.c (working copy)
@@ -28,7 +28,6 @@
 #include "svn_hash.h"
 #include "svn_path.h"
 #include "svn_ra.h"
-#include "svn_sorts.h"
 #include "svn_string.h"
 #include "svn_xml.h"
 #include "svn_props.h"
@@ -35,7 +34,6 @@
 #include "svn_base64.h"
 
 #include "private/svn_dav_protocol.h"
-#include "private/svn_sorts_private.h"
 #include "../libsvn_ra/ra_loader.h"
 #include "svn_private_config.h"
 #include "ra_serf.h"
@@ -314,8 +312,8 @@ get_iprops_via_more_requests(svn_ra_session_t *ra_
   *iprops = apr_array_make(result_pool, rq_info->nelts,
                            sizeof(svn_prop_inherited_item_t *));
 
-  /* And now create the result set */
-  for (i = 0; i < rq_info->nelts; i++)
+  /* And now create the result set in depth-first order. */
+  for (i = rq_info->nelts - 1; i >= 0; i--)
     {
       iprop_rq_info_t *rq = APR_ARRAY_IDX(rq_info, i, iprop_rq_info_t *);
       apr_hash_t *node_props;
@@ -340,7 +338,7 @@ get_iprops_via_more_requests(svn_ra_session_t *ra_
       new_iprop = apr_palloc(result_pool, sizeof(*new_iprop));
       new_iprop->path_or_url = apr_pstrdup(result_pool, rq->relpath);
       new_iprop->prop_hash = svn_prop_hash_dup(node_props, result_pool);
-      SVN_ERR(svn_sort__array_insert2(*iprops, &new_iprop, 0));
+      APR_ARRAY_PUSH(*iprops, svn_prop_inherited_item_t *) = new_iprop;
     }
 
   return SVN_NO_ERROR;

Reply via email to