Use mapTo(mutableListOf(), f) instead of map(f).toMutableList()

Proprietary

map { f } allocates a List<R> and toMutableList copies it. mapTo(mutableListOf(), f) writes directly into the target without the intermediate.

org.openrewrite.kotlin.performance.UseMapToForMapToMutableList$KtRecipe
mod run . --recipe='org.openrewrite.kotlin.performance.UseMapToForMapToMutableList$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.