Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 81309 invoked from network); 3 Oct 2007 10:43:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Oct 2007 10:43:52 -0000 Received: (qmail 67394 invoked by uid 500); 3 Oct 2007 10:43:41 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 67348 invoked by uid 500); 3 Oct 2007 10:43:41 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 67337 invoked by uid 99); 3 Oct 2007 10:43:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Oct 2007 03:43:41 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of peter.kitt.reilly@gmail.com designates 64.233.166.183 as permitted sender) Received: from [64.233.166.183] (HELO py-out-1112.google.com) (64.233.166.183) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Oct 2007 10:43:43 +0000 Received: by py-out-1112.google.com with SMTP id a73so9213308pye for ; Wed, 03 Oct 2007 03:43:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=lsK28Uz9pxTUXtiJEqnwlWO14IpDTgVRmDoU70V7Ym0=; b=dIM4UMu+bAyjOAz5gtrp/9+ZhMIBslGSFpLAK0OKJo3PQipeWvMj69AlxTdnN7CTVqTSa05CAgS6DRi4P8UbEx6/jPswWs876eHu/tj03gM5koWfg+7pbJlMK0O5XkcVEhwkzYlTjSHq+L12qGH+DZ9Og14tKH9MbNEOrgZ5mdY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Nn1hZqkLwbp2rU2EfrtnzfNxjq+KBFjvhjSk8O3s0FWUUkYCE/cerhdG4BNnyw9Mv9y92qek1CzpxzSzz30UiaFByYnyBUWmobqdouaoCKONF9G3kU37K3mgoxfWVbsqEU8nVldWtr+cy4Nyxn6mXP47mThXL0VeMorAg4crzQQ= Received: by 10.35.79.3 with SMTP id g3mr2171485pyl.1191408202374; Wed, 03 Oct 2007 03:43:22 -0700 (PDT) Received: by 10.35.97.14 with HTTP; Wed, 3 Oct 2007 03:43:22 -0700 (PDT) Message-ID: Date: Wed, 3 Oct 2007 11:43:22 +0100 From: "Peter Reilly" To: "Ant Developers List" Subject: Re: svn commit: r581394 - /ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Union.java In-Reply-To: <20071002213821.74B061A9832@eris.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20071002213821.74B061A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Why not just return the set and remove the use of arraylist? The method returns a collection. On 10/2/07, jglick@apache.org wrote: > Author: jglick > Date: Tue Oct 2 14:38:20 2007 > New Revision: 581394 > > URL: http://svn.apache.org/viewvc?rev=581394&view=rev > Log: > Silly little optimization: was taking time quadratic in fileset size. > Unfortunately this is not the only place in Ant where List.contains is called; > DirectoryScanner.processIncluded seems to be as bad. > Alas, someone long ago made protected Vector fields in DS, and it seems too late to change them now: > even changing to ArrayList would break subclasses like FTP which call addElement! Yuck!! Peter > > Modified: > ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Union.java > > Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Union.java > URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Union.java?rev=581394&r1=581393&r2=581394&view=diff > ============================================================================== > --- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Union.java (original) > +++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/Union.java Tue Oct 2 14:38:20 2007 > @@ -22,6 +22,8 @@ > import java.util.ArrayList; > import java.util.Collection; > import java.util.Collections; > +import java.util.HashSet; > +import java.util.Set; > > import org.apache.tools.ant.types.Resource; > import org.apache.tools.ant.types.ResourceCollection; > @@ -100,14 +102,16 @@ > return Collections.EMPTY_LIST; > } > //preserve order-encountered using a list; enforce set logic manually: > + // (LinkedHashSet better, but JDK 1.4+) > ArrayList union = new ArrayList(rc.size() * 2); > + Set _union = new HashSet(rc.size() * 2); > for (Iterator rcIter = rc.iterator(); rcIter.hasNext();) { > for (Iterator r = nextRC(rcIter).iterator(); r.hasNext();) { > Object o = r.next(); > if (asString) { > o = o.toString(); > } > - if (!(union.contains(o))) { > + if (_union.add(o)) { > union.add(o); > } > } > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org > For additional commands, e-mail: dev-help@ant.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org