Use primitive mutable<Int|Long|Float|Double>StateOf in Compose

Proprietary

Inside @Composable functions, replaces mutableStateOf(<primitive>) with the matching primitive-specialized mutableIntStateOf/mutableLongStateOf/mutableFloatStateOf/mutableDoubleStateOf. The specialized state holders keep the wrapped value unboxed across reads and writes during recomposition.

org.openrewrite.kotlin.performance.UseComposePrimitiveStateOf$KtRecipe
mod run . --recipe='org.openrewrite.kotlin.performance.UseComposePrimitiveStateOf$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. Use mutableIntStateOf instead of mutableStateOf<Int> in Compose
  2. Use mutableLongStateOf instead of mutableStateOf<Long> in Compose
  3. Use mutableFloatStateOf instead of mutableStateOf<Float> in Compose
  4. Use mutableDoubleStateOf instead of mutableStateOf<Double> in Compose