Use max() instead of sortedDescending().first()

Proprietary

sortedDescending().first() does an O(n log n) sort just to read the maximum. max() finds it in a single linear pass.

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