mrmans0n / compose-rules

Lint rules for ktlint/detekt aimed to contribute to a healthier usage of Compose. Actively maintained and evolved fork of the Twitter Compose rules.
https://mrmans0n.github.io/compose-rules
Other
543 stars 20 forks source link

Add rule to use the non-autoboxing versions of mutableStateOf when possible #221

Closed mrmans0n closed 4 months ago

mrmans0n commented 4 months ago

mutableIntStateOf, mutableLongStateOf, mutableDoubleStateOf, mutableFloatStateOf are essentially counterparts to mutableStateOf, but with the added advantage of circumventing autoboxing on JVM platforms. This distinction renders them more memory efficient, making them the preferable choice when dealing with primitive types such as double, float, int, and long.

There is an official lint rule already for this, but lint won't help with KMP projects like the one I work on at my day job, so detecting this is useful anyway.