Use filterNotTo(mutableListOf(), p) instead of filterNot(p).toMutableList()

Proprietary

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

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