Does it make sense to cache values of frequently u...
# compose
s
Does it make sense to cache values of frequently used calculations or extensions, like
.dp
,
RoundedCornerShape
,, etc. in some global space?
Copy code
// some global .kt file
val cornerShape = RoundedCornerShape(3.dp)
val imageSizeLarge = 120.dp
...
Or does the Compose compiler take care of it, and we are free to reuse those same values all over the place? Or are they so cheap to create that it is even encouraged to write them out each time?
Would “globalizing” such frequently used values positively affect performance in any way, for example in a lazy list?
z
Write code that is simple and easy to read and maintain first. If you’re using a shape in enough places for it to really matter for performance then there are probably other reasons to factor it out anyway.
🙏 1