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: <javac> 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!

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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to