subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pbu...@apache.org
Subject svn commit: r1181090 - in /subversion/trunk/subversion: include/svn_sorts.h libsvn_client/merge.c libsvn_subr/mergeinfo.c libsvn_subr/sorts.c
Date Mon, 10 Oct 2011 17:40:57 GMT
Author: pburba
Date: Mon Oct 10 17:40:57 2011
New Revision: 1181090

URL: http://svn.apache.org/viewvc?rev=1181090&view=rev
Log:
Follow-up to r1180154: svn_rangelist_merge2 optimization.

Suggested by: philip

* subversion/include/svn_sorts.h

  (svn_sort__array_delete): Add an argument specifying the number of elements
   to delete.

* subversion/libsvn_client/merge.c

  (remove_absent_children,
   remove_children_with_deleted_mergeinfo): Update calls to
   svn_sort__array_delete.

* subversion/libsvn_subr/mergeinfo.c

  (adjust_remaining_ranges): Make a single call to svn_sort__array_delete
   rather than iterating over each deleted element.

* subversion/libsvn_subr/sorts.c

  (svn_sort__array_delete): Add an argument specifying the number of elements
   to delete.

Modified:
    subversion/trunk/subversion/include/svn_sorts.h
    subversion/trunk/subversion/libsvn_client/merge.c
    subversion/trunk/subversion/libsvn_subr/mergeinfo.c
    subversion/trunk/subversion/libsvn_subr/sorts.c

Modified: subversion/trunk/subversion/include/svn_sorts.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_sorts.h?rev=1181090&r1=1181089&r2=1181090&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_sorts.h (original)
+++ subversion/trunk/subversion/include/svn_sorts.h Mon Oct 10 17:40:57 2011
@@ -182,11 +182,15 @@ svn_sort__array_insert(const void *new_e
                        int insert_index);
 
 
-/* Remove the element at DELETE_INDEX from the array ARR.
-   If DELETE_INDEX is not a valid element of ARR do nothing. */
+/* Remove ELEMENTS_TO_DELETE elements starting  at DELETE_INDEX from the
+   array ARR. If DELETE_INDEX is not a valid element of ARR,
+   ELEMENTS_TO_DELETE is not greater than zero, or
+   DELETE_INDEX + ELEMENTS_TO_DELETE is grater than ARR->NELTS, then do
+   nothing. */
 void
 svn_sort__array_delete(apr_array_header_t *arr,
-                       int delete_index);
+                       int delete_index,
+                       int elements_to_delete);
 
 #ifdef __cplusplus
 }

Modified: subversion/trunk/subversion/libsvn_client/merge.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/merge.c?rev=1181090&r1=1181089&r2=1181090&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/merge.c (original)
+++ subversion/trunk/subversion/libsvn_client/merge.c Mon Oct 10 17:40:57 2011
@@ -4795,7 +4795,7 @@ remove_absent_children(const char *targe
       if ((child->absent || child->scheduled_for_deletion)
           && svn_dirent_is_ancestor(target_wcpath, child->abspath))
         {
-          svn_sort__array_delete(children_with_mergeinfo, i--);
+          svn_sort__array_delete(children_with_mergeinfo, i--, 1);
         }
     }
 }
@@ -4831,7 +4831,7 @@ remove_children_with_deleted_mergeinfo(m
                        child->abspath,
                        APR_HASH_KEY_STRING))
         {
-          svn_sort__array_delete(notify_b->children_with_mergeinfo, i--);
+          svn_sort__array_delete(notify_b->children_with_mergeinfo, i--, 1);
         }
     }
 }

Modified: subversion/trunk/subversion/libsvn_subr/mergeinfo.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/mergeinfo.c?rev=1181090&r1=1181089&r2=1181090&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/mergeinfo.c (original)
+++ subversion/trunk/subversion/libsvn_subr/mergeinfo.c Mon Oct 10 17:40:57 2011
@@ -902,8 +902,7 @@ adjust_remaining_ranges(apr_array_header
     }
 
   if (elements_to_delete)
-    for (i = starting_index; i < (elements_to_delete + starting_index); i++)
-      svn_sort__array_delete(rangelist, starting_index);
+    svn_sort__array_delete(rangelist, starting_index, elements_to_delete);
 }
 
 svn_error_t *

Modified: subversion/trunk/subversion/libsvn_subr/sorts.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/sorts.c?rev=1181090&r1=1181089&r2=1181090&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/sorts.c (original)
+++ subversion/trunk/subversion/libsvn_subr/sorts.c Mon Oct 10 17:40:57 2011
@@ -248,21 +248,31 @@ svn_sort__array_insert(const void *new_e
 
 void
 svn_sort__array_delete(apr_array_header_t *arr,
-                       int delete_index)
+                       int delete_index,
+                       int elements_to_delete)
 {
-  /* Do we have a valid index? */
-  if (delete_index >= 0 && delete_index < arr->nelts)
+  /* Do we have a valid index and are there enough elements? */
+  if (delete_index >= 0
+      && delete_index < arr->nelts
+      && elements_to_delete > 0
+      && (elements_to_delete + delete_index) <= arr->nelts)
     {
       if (delete_index == (arr->nelts - 1))
         {
           /* Deleting the last or only element in an array is easy. */
           apr_array_pop(arr);
         }
+      else if ((delete_index + elements_to_delete) == arr->nelts)
+        {
+          /* Delete the last ELEMENTS_TO_DELETE elements. */
+          arr->nelts -= elements_to_delete;
+        }
       else
         {
           memmove(arr->elts + arr->elt_size * delete_index,
                   arr->elts + arr->elt_size * (delete_index + 1),
-                  arr->elt_size * (arr->nelts - 1 - delete_index));
+                  arr->elt_size * (arr->nelts - 1 - delete_index)
+                  * elements_to_delete);
           --(arr->nelts);
         }
     }



Mime
View raw message