On Mon, Oct 10, 2011 at 3:48 AM, Philip Martin
<philip.martin_at_wandisco.com> wrote:
> pburba_at_apache.org writes:
>
>> Author: pburba
>> Date: Fri Oct 7 19:00:40 2011
>> New Revision: 1180154
>
>> + if (elements_to_delete)
>> + for (i = starting_index; i < (elements_to_delete + starting_index); i++)
>> + svn_sort__array_delete(rangelist, starting_index);
>> +}
>
> Given the pop optimisation it would be more efficient to delete the
> elements in reverse order. Passing the number of elements to be deleted
> to svn_sort__array_delete would be better.
Did the latter in r118109.0
Paul
>> +void
>> +svn_sort__array_delete(apr_array_header_t *arr,
>> + int delete_index)
>> +{
>> + /* Do we have a valid index? */
>> + if (delete_index >= 0 && 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
>> + {
>> + 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->nelts);
>> + }
>> + }
>> +}
>
> --
> Philip
>
Received on 2011-10-10 19:42:01 CEST