Author: jglick
Date: Tue Oct  2 14:39:20 2007
New Revision: 581395

URL: http://svn.apache.org/viewvc?rev=581395&view=rev
Log:
optimization; merge of 581394 from trunk

Modified:
    
ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/types/resources/Union.java

Modified: 
ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/types/resources/Union.java
URL: 
http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/types/resources/Union.java?rev=581395&r1=581394&r2=581395&view=diff
==============================================================================
--- 
ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/types/resources/Union.java
 (original)
+++ 
ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/types/resources/Union.java
 Tue Oct  2 14:39: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