Skip to content

Commit

Permalink
Use Stream.builder instead of ArrayList (#467)
Browse files Browse the repository at this point in the history
  • Loading branch information
pivovarit authored Mar 19, 2020
1 parent 7a89f40 commit c1f3d36
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ static void requireValidParallelism(int parallelism) {

static <T, R, RR> Collector<T, ?, CompletableFuture<RR>> asyncCollector(Function<T, R> mapper, Executor executor, Function<Stream<R>, RR> finisher) {
return collectingAndThen(toList(), list -> supplyAsync(() -> {
List<R> acc = new ArrayList<>(list.size());
Stream.Builder<R> acc = Stream.builder();
for (T t : list) {
acc.add(mapper.apply(t));
}
return finisher.apply(acc.stream());
return finisher.apply(acc.build());
}, executor));
}

Expand Down

0 comments on commit c1f3d36

Please sign in to comment.