Use firstNotNullOfOrNull { f } instead of mapNotNull { f }.firstOrNull()

Proprietary

firstNotNullOfOrNull short-circuits on the first non-null result. mapNotNull { f }.firstOrNull() walks the whole input.

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