Are there any downsides/ performance impacts when using Generic composable function?
e.g
Copy code
@Composable
fun <T> CardList(
items: List<T>,
) {
// TODO Draw your list here.
}
m
Marco Pierucci
11/17/2022, 10:06 AM
I have a few of them on a prod app and have not seen any particular performance issue ( related to generic that is 😅)
z
Zach Klippenstein (he/him) [MOD]
11/17/2022, 10:46 PM
tl;dr: No, I’m pretty sure.
The only way I can think this could potentially affect performance is that it might prevent compose from inferring stability in some cases that it would without generics. But I wouldn’t worry about that until you’re profiling benchmarks, and in your example code it wouldn’t happen since