From 19de811cafeb55fb519965cd89427416798e3040 Mon Sep 17 00:00:00 2001 From: Thomas Neidhart Date: Tue, 19 Jun 2012 18:59:46 +0000 Subject: [PATCH] [COLLECTIONS-407] improve performance of remove method by taking method result from underlying collection into account. Thanks to Adrian Nistor for reporting and providing a patch. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1351800 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/commons/collections/set/ListOrderedSet.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/commons/collections/set/ListOrderedSet.java b/src/main/java/org/apache/commons/collections/set/ListOrderedSet.java index 0b5cfa3c7..d68ac8302 100644 --- a/src/main/java/org/apache/commons/collections/set/ListOrderedSet.java +++ b/src/main/java/org/apache/commons/collections/set/ListOrderedSet.java @@ -42,7 +42,7 @@ import org.apache.commons.collections.list.UnmodifiableList; * the set can be obtained via asList(). *

* This class cannot implement the List interface directly as - * various interface methods (notably equals/hashCode) are incompatable with a set. + * various interface methods (notably equals/hashCode) are incompatible with a set. *

* This class is Serializable from Commons Collections 3.1. * @@ -200,7 +200,9 @@ public class ListOrderedSet extends AbstractSerializableSetDecorator imple @Override public boolean remove(Object object) { boolean result = collection.remove(object); - setOrder.remove(object); + if (result) { + setOrder.remove(object); + } return result; }