Just curious, how does Compose Compiler handle Com...
# compose
l
Just curious, how does Compose Compiler handle Composable invocation inside inline lambda passed to inline fun? for example,
Copy code
list.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?
z
I’m not sure about the exact details of how compose generates groups, but I believe the answer is no. The way Kotlin inlining works is, I believe, that the body of
forEach
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.