Skip to content

Commit c4a7c66

Browse files
committed
Use for loops instead of streams
1 parent d848c41 commit c4a7c66

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/main/java/org/apache/maven/plugin/compiler/DeltaList.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,29 @@
2020

2121
import java.util.Collection;
2222
import java.util.Collections;
23-
import java.util.List;
24-
import java.util.stream.Collectors;
23+
import java.util.Set;
24+
import java.util.TreeSet;
2525

2626
/**
2727
* Show the modifications between two lists.
2828
*/
29-
final class DeltaList<E> {
29+
final class DeltaList<E extends Comparable<E>> {
3030

31-
private final List<E> added;
32-
private final List<E> removed;
31+
private final Set<E> added = new TreeSet<>();
32+
private final Set<E> removed = new TreeSet<>();
3333
private final boolean hasChanged;
3434

3535
DeltaList(Collection<E> oldList, Collection<E> newList) {
36-
this.added = newList.stream().filter(i -> !oldList.contains(i)).sorted().collect(Collectors.toList());
37-
this.removed =
38-
oldList.stream().filter(i -> !newList.contains(i)).sorted().collect(Collectors.toList());
36+
for (E newListItem : newList) {
37+
if (!oldList.contains(newListItem)) {
38+
added.add(newListItem);
39+
}
40+
}
41+
for (E oldListItem : oldList) {
42+
if (!newList.contains(oldListItem)) {
43+
removed.add(oldListItem);
44+
}
45+
}
3946
this.hasChanged = !added.isEmpty() || !removed.isEmpty();
4047
}
4148

0 commit comments

Comments
 (0)