| Reporter: |
|
Joachim Rudolph |
| Created: |
|
Wed, 13 Aug 2008 04:00:05 -0700 (PDT) |
| Updated: |
|
Mon, 3 Nov 2008 08:36:11 -0800 (PST) |
| Key: |
|
COLLECTIONS-302 |
| Versions: |
|
Not provided |
| Environment: |
|
|
| Priority: |
|
4 |
| Status: |
|
Closed |
| Resolution: |
|
Won't Fix |
| Original Link: |
|
http://issues.apache.org/jira/browse/COLLECTIONS-302 |
| Summary: |
|
CollectionUtils.subtract() should not use ArrayList to improve speed |
Description:
The implementation of version 3.2.1 is
public static Collection subtract(final Collection a, final Collection b) {
ArrayList list = new ArrayList( a );
for (Iterator it = b.iterator(); it.hasNext()<img class="emoticon" src="
https://issues.apache.org/jira/images/icons/emoticons/wink.gif" height="20" width="20" align="absmiddle" alt="" border="0"/> {
list.remove(it.next());
}
return list;
}
when a and b are large and similar the subtract implementation will call ArrayList.remove() frequently which copies a potentially large part of the list using system.arraycopy.
<p>Suggestion : use LinkedList ( at least for large lists )</p>
Comments:
| bayard |
Thu, 23 Oct 2008 20:58:48 -0700 (PDT) |
| joarud |
Fri, 24 Oct 2008 04:48:59 -0700 (PDT) |
| bayard |
Mon, 3 Nov 2008 08:36:11 -0800 (PST) |