Return-Path: X-Original-To: apmail-subversion-dev-archive@minotaur.apache.org Delivered-To: apmail-subversion-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1C58D714E for ; Mon, 10 Oct 2011 10:49:32 +0000 (UTC) Received: (qmail 85428 invoked by uid 500); 10 Oct 2011 10:49:31 -0000 Delivered-To: apmail-subversion-dev-archive@subversion.apache.org Received: (qmail 85382 invoked by uid 500); 10 Oct 2011 10:49:31 -0000 Mailing-List: contact dev-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@subversion.apache.org Received: (qmail 85375 invoked by uid 99); 10 Oct 2011 10:49:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Oct 2011 10:49:31 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [81.103.221.49] (HELO mtaout03-winn.ispmail.ntl.com) (81.103.221.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Oct 2011 10:49:22 +0000 Received: from aamtaout04-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout03-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20111010104900.QSKE8898.mtaout03-winn.ispmail.ntl.com@aamtaout04-winn.ispmail.ntl.com> for ; Mon, 10 Oct 2011 11:49:00 +0100 Received: from cpc2-farn6-0-0-cust204.6-2.cable.virginmedia.com ([86.16.124.205]) by aamtaout04-winn.ispmail.ntl.com (InterMail vG.3.00.04.00 201-2196-133-20080908) with ESMTP id <20111010104900.IPAN25656.aamtaout04-winn.ispmail.ntl.com@cpc2-farn6-0-0-cust204.6-2.cable.virginmedia.com> for ; Mon, 10 Oct 2011 11:49:00 +0100 Received: by cpc2-farn6-0-0-cust204.6-2.cable.virginmedia.com (Postfix, from userid 1000) id 2E79636225; Mon, 10 Oct 2011 11:48:58 +0100 (BST) From: Philip Martin To: dev@subversion.apache.org Subject: Re: svn commit: r1180154 - in /subversion/trunk/subversion: include/svn_sorts.h libsvn_client/merge.c libsvn_subr/mergeinfo.c libsvn_subr/sorts.c tests/libsvn_subr/mergeinfo-test.c References: <20111007190041.C233B2388A32@eris.apache.org> Date: Mon, 10 Oct 2011 11:48:58 +0100 In-Reply-To: <20111007190041.C233B2388A32@eris.apache.org> (pburba@apache.org's message of "Fri, 07 Oct 2011 19:00:41 -0000") Message-ID: <87obxp5dgl.fsf@stat.home.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Cloudmark-Analysis: v=1.1 cv=R50lirqlHffDPPkwUlkuVa99MrvKdVWo//yz83qex8g= c=1 sm=0 a=dmETdrZ3I3YA:10 a=CGjUDyhUAXUA:10 a=sOaj6hhuNKAA:10 a=kj9zAlcOel0A:10 a=mV9VRH-2AAAA:8 a=X_KTJzsoGVD63YMhbwkA:9 a=hg3MUnFgA8NUcXtSXVAA:7 a=CjuIK1q_8ugA:10 a=88iI8knYSJUA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 pburba@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. > +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