Use filterTo(mutableListOf(), p) instead of filter(p).toMutableList()

Proprietary

filter { p } allocates a List<T> and toMutableList copies it. filterTo(mutableListOf(), p) writes directly into the target without the intermediate.

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