lhwdev
04/29/2021, 5:01 AMlist.forEach { MyComposable(it) }
AFAIK, I cannot know the body of external declaration stubs, like stdlib here. Also heard that inlining occurs in 'linking phase'.
Then does compiler plugin generate an additional group for this loop?Zach Klippenstein (he/him) [MOD]
04/29/2021, 2:01 PMforEach
is actually stored in the kotlin metadata, so the compiler can copy the body into the bytecode of wherever it’s called (i don’t know which phase it happens in though). I think the compose compiler ends up seeing the already-inlined bytecode, so as far as Compose is concerned this is just a regular loop.
This is why you generally need to use compose’s key
function inside of loops – the compiler doesn’t have enough information to generate unique keys for multiple calls of the same composable from the same location.