This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-collections.git
The following commit(s) were added to refs/heads/master by this push: new 07b82f6 Simplify two remove-if loops (#77) 07b82f6 is described below commit 07b82f6a698dac3f2e6c9f6407776566763be11e Author: Eitan Adler <grimrea...@users.noreply.github.com> AuthorDate: Wed Jul 10 07:39:51 2019 -0700 Simplify two remove-if loops (#77) These are semantically identical easier to read. --- .../apache/commons/collections4/list/CursorableLinkedList.java | 7 +------ .../java/org/apache/commons/collections4/set/ListOrderedSet.java | 8 ++------ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/apache/commons/collections4/list/CursorableLinkedList.java b/src/main/java/org/apache/commons/collections4/list/CursorableLinkedList.java index ddc63dd..ea02b21 100644 --- a/src/main/java/org/apache/commons/collections4/list/CursorableLinkedList.java +++ b/src/main/java/org/apache/commons/collections4/list/CursorableLinkedList.java @@ -274,12 +274,7 @@ public class CursorableLinkedList<E> extends AbstractLinkedList<E> implements Se protected void registerCursor(final Cursor<E> cursor) { // We take this opportunity to clean the cursors list // of WeakReference objects to garbage-collected cursors. - for (final Iterator<WeakReference<Cursor<E>>> it = cursors.iterator(); it.hasNext();) { - final WeakReference<Cursor<E>> ref = it.next(); - if (ref.get() == null) { - it.remove(); - } - } + cursors.removeIf(ref -> ref.get() == null); cursors.add(new WeakReference<>(cursor)); } diff --git a/src/main/java/org/apache/commons/collections4/set/ListOrderedSet.java b/src/main/java/org/apache/commons/collections4/set/ListOrderedSet.java index ce9d300..d9e89c4 100644 --- a/src/main/java/org/apache/commons/collections4/set/ListOrderedSet.java +++ b/src/main/java/org/apache/commons/collections4/set/ListOrderedSet.java @@ -261,14 +261,10 @@ public class ListOrderedSet<E> if (result == false) { return false; } - if (decorated().size() == 0) { + if (decorated().isEmpty()) { setOrder.clear(); } else { - for (final Iterator<E> it = setOrder.iterator(); it.hasNext();) { - if (!decorated().contains(it.next())) { - it.remove(); - } - } + setOrder.removeIf(e -> !decorated().contains(e)); } return result; }