commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1090712 - /commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/classes/DiscoverClasses.java
Date Sat, 09 Apr 2011 23:50:51 GMT
Author: simonetripodi
Date: Sat Apr  9 23:50:51 2011
New Revision: 1090712

URL: http://svn.apache.org/viewvc?rev=1090712&view=rev
Log:
using an hashset is more canonical to store already load resources

Modified:
    commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/classes/DiscoverClasses.java

Modified: commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/classes/DiscoverClasses.java
URL: http://svn.apache.org/viewvc/commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/classes/DiscoverClasses.java?rev=1090712&r1=1090711&r2=1090712&view=diff
==============================================================================
--- commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/classes/DiscoverClasses.java
(original)
+++ commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/classes/DiscoverClasses.java
Sat Apr  9 23:50:51 2011
@@ -18,8 +18,8 @@ package org.apache.commons.discovery.res
 
 import java.net.URL;
 import java.security.CodeSource;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.HashSet;
+import java.util.Set;
 
 import org.apache.commons.discovery.ResourceClass;
 import org.apache.commons.discovery.ResourceClassDiscover;
@@ -77,7 +77,7 @@ public class DiscoverClasses<T> extends 
 
         return new ResourceClassIterator<T>() {
 
-            private final List<URL> history = new ArrayList<URL>();
+            private final Set<URL> history = new HashSet<URL>();
 
             private int idx = 0;
 
@@ -124,9 +124,7 @@ public class DiscoverClasses<T> extends 
                     }
 
                     if (url != null) {
-                        if (!history.contains(url)) {
-                            history.add(url);
-
+                        if (history.add(url)) {
                             if (log.isDebugEnabled()) {
                                 log.debug("getNextClass: next URL='" + url + "'");
                             }



Mime
View raw message