Use toSet() instead of distinct().toSet()

Proprietary

toSet() deduplicates while building the set. distinct().toSet() allocates a List of distinct elements first, then copies into the set.

org.openrewrite.kotlin.bestpractices.UseToSetForDistinctThenToSet$KtRecipe
mod 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.