diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 7e5de72e9..8a8f23030 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -22,7 +22,9 @@ - Dummy + + Improved performance of ListOrderedMap#remove(Object) method. + diff --git a/src/main/java/org/apache/commons/collections/map/ListOrderedMap.java b/src/main/java/org/apache/commons/collections/map/ListOrderedMap.java index 09d9001be..4d6facb6d 100644 --- a/src/main/java/org/apache/commons/collections/map/ListOrderedMap.java +++ b/src/main/java/org/apache/commons/collections/map/ListOrderedMap.java @@ -251,8 +251,11 @@ public class ListOrderedMap @Override public V remove(Object key) { - V result = decorated().remove(key); - insertOrder.remove(key); + V result = null; + if (decorated().containsKey(key)) { + result = decorated().remove(key); + insertOrder.remove(key); + } return result; }