Use lastOrNull { predicate } instead of filter { predicate }.lastOrNull()

Proprietary

Folding the predicate into lastOrNull avoids materializing the intermediate filtered list.

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