qlitzler
10/03/2022, 12:27 PMandroidx.compose.ui.graphics.Path
, and by extension an android.graphics.Path
, be considered as @Stable
or @Immutable
?
I know the compose compiler doesn’t think so by default. I’m trying to assess if I could add the @Stable
or @Immutable
annotation myself.Zach Klippenstein (he/him) [MOD]
10/04/2022, 10:52 AMqlitzler
10/04/2022, 10:54 AMPath
and having the method / class marked as stable right ?qlitzler
10/04/2022, 10:59 AM// Can't be stable
class Sprite(val path: Path) {
fun draw(scope: DrawScope) {
scope.drawPath(path)
}
}
// Won't be skippable
@Composable
Sprite.Compose() {
Canvas {
draw(this)
}
}
Zach Klippenstein (he/him) [MOD]
10/04/2022, 11:09 AMqlitzler
10/04/2022, 11:17 AMPath
will never be updated again once initialised and passed to the Sprite
class, I can mark the Sprite
class as @Stable
or even @Immutable
and enjoy the optimisation, if I understood you correctly ?Zach Klippenstein (he/him) [MOD]
10/04/2022, 11:32 AM