You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given a stream of elements that must be filtered and sorted, it is generally more efficient to do the former first, so that the subsequent sorting step involves fewer elements. This applies to Stream, IntStream, LongStream, DoubleStream and Flux types.
Description of the proposed new feature
Support a stylistic preference.
Avoid a common gotcha, or potential problem.
Rewrite:
stream.sorted().filter(pred)
to:
stream.filter(pred).sorted()
Do the same for the other types mentioned above, as well as Comparator-accepting sort method overloads.
Considerations
One nice advantage of the proposed rewrite rules is that these simplifications might subsequently kick in.
The text was updated successfully, but these errors were encountered:
Problem
Given a stream of elements that must be filtered and sorted, it is generally more efficient to do the former first, so that the subsequent sorting step involves fewer elements. This applies to
Stream
,IntStream
,LongStream
,DoubleStream
andFlux
types.Description of the proposed new feature
Rewrite:
to:
Do the same for the other types mentioned above, as well as
Comparator
-accepting sort method overloads.Considerations
One nice advantage of the proposed rewrite rules is that these simplifications might subsequently kick in.
The text was updated successfully, but these errors were encountered: