From da83de9208e2efceaf836a155abb5c2446f2dd46 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Fri, 20 Feb 2015 10:11:09 +0100 Subject: [PATCH] performance improvement for Bugzilla Issue 57588 --- WHATSNEW | 3 +++ .../tools/ant/types/resources/Intersect.java | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index ca81b8bf4..82f78ac6f 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -98,6 +98,9 @@ Other changes: * adapted unit tests to Java9 and added "javac1.9" as valid option for javac's compiler attribute. + * performance improvements for + Bugzilla Report 57588 + Changes from Ant 1.9.3 TO Ant 1.9.4 =================================== diff --git a/src/main/org/apache/tools/ant/types/resources/Intersect.java b/src/main/org/apache/tools/ant/types/resources/Intersect.java index 301df7c06..cdbeed0f7 100644 --- a/src/main/org/apache/tools/ant/types/resources/Intersect.java +++ b/src/main/org/apache/tools/ant/types/resources/Intersect.java @@ -17,10 +17,11 @@ */ package org.apache.tools.ant.types.resources; -import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.List; +import java.util.Set; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.types.Resource; @@ -45,17 +46,16 @@ public class Intersect extends BaseResourceCollectionContainer { + " resource collection" + ((size == 1) ? "" : "s") + " is undefined."); } - List al = new ArrayList(); Iterator rc = rcs.iterator(); - al.addAll(collect(rc.next())); + Set s = new LinkedHashSet(collect(rc.next())); while (rc.hasNext()) { - al.retainAll(collect(rc.next())); + s.retainAll(collect(rc.next())); } - return al; + return s; } - private List collect(ResourceCollection rc) { - List result = new ArrayList(); + private Set collect(ResourceCollection rc) { + Set result = new LinkedHashSet(); for (Resource r : rc) { result.add(r); }