Skip to content

Commit 36fc91c

Browse files
committed
FpKit now longer uses streams for performance reasons - tweak
1 parent 26bb001 commit 36fc91c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/graphql/util/FpKit.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static <T, NewKey> Map<NewKey, T> toMap(Collection<T> collection, Functio
5555

5656
// normal groupingBy but with LinkedHashMap
5757
public static <T, NewKey> Map<NewKey, ImmutableList<T>> groupingBy(Collection<T> list, Function<T, NewKey> function) {
58-
return filterAndGroupingBy(list, t -> true, function);
58+
return filterAndGroupingBy(list, ALWAYS_TRUE, function);
5959
}
6060

6161
@SuppressWarnings("unchecked")
@@ -93,10 +93,13 @@ public static <T, NewKey> Map<NewKey, T> toMapByUniqueKey(Collection<T> list, Fu
9393
}
9494

9595

96+
private static final Predicate<Object> ALWAYS_TRUE = o -> true;
97+
9698
private static final BinaryOperator<Object> THROWING_MERGER_SINGLETON = (u, v) -> {
9799
throw new IllegalStateException(String.format("Duplicate key %s", u));
98100
};
99101

102+
100103
private static <T> BinaryOperator<T> throwingMerger() {
101104
//noinspection unchecked
102105
return (BinaryOperator<T>) THROWING_MERGER_SINGLETON;

0 commit comments

Comments
 (0)