[COLLECTIONS-410] Improved performance of SetUniqueList.addAll(index, coll). Thanks to Adrian Nistor for reporting and providing a patch.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1352243 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas Neidhart 2012-06-20 18:04:19 +00:00
parent ff9488b31e
commit a753ba0a03
1 changed files with 4 additions and 9 deletions

View File

@ -192,18 +192,13 @@ public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
*/
@Override
public boolean addAll(int index, Collection<? extends E> coll) {
HashSet<E> temp = new HashSet<E>(coll);
temp.removeAll(set);
if (temp.isEmpty()) {
return false;
}
final List<E> temp = new ArrayList<E>();
for (E e : coll) {
if (temp.contains(e)) {
add(index, e);
index++;
if (set.add(e)) {
temp.add(e);
}
}
return true;
return super.addAll(index, temp);
}
//-----------------------------------------------------------------------