diff --git a/api/src/main/java/net/jqwik/api/ShrinkingDistance.java b/api/src/main/java/net/jqwik/api/ShrinkingDistance.java index 29375367b..8768d206c 100644 --- a/api/src/main/java/net/jqwik/api/ShrinkingDistance.java +++ b/api/src/main/java/net/jqwik/api/ShrinkingDistance.java @@ -4,6 +4,7 @@ import java.util.stream.*; import org.apiguardian.api.*; +import org.jetbrains.annotations.*; import static org.apiguardian.api.API.Status.*; @@ -41,9 +42,7 @@ public static ShrinkingDistance combine(List> shrinkables) { throw new IllegalArgumentException("At least one shrinkable is required"); } // This is an optimization to avoid creating many temporary arrays, which the old streams-based implementation did. - List shrinkableDistances = shrinkables.stream() - .map(tShrinkable -> tShrinkable.distance().distances) - .collect(Collectors.toList()); + List shrinkableDistances = toDistances(shrinkables); long[] combinedDistances = concatenate(shrinkableDistances); return new ShrinkingDistance(combinedDistances); } @@ -120,4 +119,14 @@ public ShrinkingDistance append(ShrinkingDistance other) { return new ShrinkingDistance(appendedDistances); } + @NotNull + private static List toDistances(List> shrinkables) { + List listOfDistances = new ArrayList<>(shrinkables.size()); + for (Shrinkable tShrinkable : shrinkables) { + long[] longs = tShrinkable.distance().distances; + listOfDistances.add(longs); + } + return listOfDistances; + } + }