-
Notifications
You must be signed in to change notification settings - Fork 48
Description
Problem
Performing an expensive sort operation on data that will largely be discarded by the subsequent distinct operation should be avoided.
Description of the proposed new feature
- Support a stylistic preference.
- Avoid a common gotcha, or potential problem.
- Improve performance.
I would like to rewrite the following code:
stream.sorted().distinct()
// Rewrite to:
stream.distinct().sorted()flux.sort().distinct()
// Rewrite to:
flux.distinct().sort()Considerations
These rewrite rules can be implemented using Refaster by adding new rules to StreamRules and ReactorRules respectively.
Consider the overloads of the sort, sorted, and distinct APIs.
Participation
- I am willing to submit a pull request to implement this improvement.
Copilot