Find collection construction inside loops

Proprietary

Flags listOf / mutableListOf / mutableMapOf calls that allocate a fresh collection on every loop iteration. Hoist constants or clear()-and-reuse a single instance.

org.openrewrite.kotlin.performance.FindLoopAllocations$KtRecipe
mod run . --recipe='org.openrewrite.kotlin.performance.FindLoopAllocations$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. Find listOf(...) calls inside loops
  2. Find mutableListOf<T>() allocations inside loops
  3. Find mutableMapOf<K, V>() allocations inside loops