Will `onItemClick` actually get inlined? I inlined...
# announcements
r
Will
onItemClick
actually get inlined? I inlined it with the intention to improve performance, but I haven't seen
inline
used in a constructor before.
Copy code
class MyAdapter(private inline val onItemClick: (Item) -> Unit) {
   //...
}
m
No. You probably don’t inline anything there. You cannot inline lambdas that aren’t called immediately.
What are you trying to optimize?
r
Thank you!
MyAdapter
is an androidx RecyclerView adapter using dataBinding.
onItemClick
is the function executed when a row is clicked. I'm playing around with different ways to pass an onClick function to the ViewHolder.
m
If there is only one lambda per adapter then that is shared across all view holders then it’s very cheap and you can’t optimize it much more.
r
Yep! Thank you for the help and explanation!
🙌 1