Apply Kotlin performance idioms
ProprietaryOpinionated 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$KtRecipemod 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.
- Collapse
filter { p }.<terminal>()chains - Collapse
sorted().first/last()andreversed().first/last()chains - Use primitive
mutable<Int|Long|Float|Double>StateOfin Compose - Use
sb.lengthinstead ofsb.toString().length - Find expensive allocations on hot paths
- Find expensive allocations inside collection lambdas
- Find
Sequence/Listpipeline shape smells - Find string-allocation smells
- Find collection construction inside loops
- Find iteration-shape smells