Apply Kotlin performance idioms

Proprietary

Opinionated bundle of every performance recipe in this module: chain collapses (filter/map/sort/reverse), Compose primitive-state holders, and hot-path allocation finders. Search-result recipes coexist with rewriting recipes — for diff-only output, use ImproveKotlinPerformance instead.

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

Recipe list

It runs these recipes, in this order.

  1. Collapse filter { p }.<terminal>() chains
  2. Collapse sorted().first/last() and reversed().first/last() chains
  3. Use primitive mutable<Int|Long|Float|Double>StateOf in Compose
  4. Use sb.length instead of sb.toString().length
  5. Find expensive allocations on hot paths
  6. Find expensive allocations inside collection lambdas
  7. Find Sequence/List pipeline shape smells
  8. Find string-allocation smells
  9. Find collection construction inside loops
  10. Find iteration-shape smells