Use toSet() instead of distinct().toSet()
ProprietarytoSet() deduplicates while building the set. distinct().toSet() allocates a List of distinct elements first, then copies into the set.
org. openrewrite. kotlin. bestpractices. UseToSetForDistinctThenToSet$KtRecipemod run . --recipe= 'org. openrewrite. kotlin. bestpractices. UseToSetForDistinctThenToSet$KtRecipe'Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.