Anton Shilov03/04/2022, 11:29 AM
callback is considered a bad practice. In compose official docs we see creating instances of Offset, Path, etc. in DrawScope. Is it going to be impacting draw performance the same way as in views? Or we shouldn't care about such things in compose world?
Filip Wiesner03/04/2022, 11:47 AM
is inline (value) class so that shouldn't be a problem
ade03/04/2022, 12:20 PM
Anton Shilov03/04/2022, 12:35 PM
Albert Chang03/04/2022, 2:07 PM
) are inline classes, which are essentially primitive types, so there isn’t any object allocations when using these classes. Secondly, that rule was proposed in the early years of Android, when it was still using Dalvik. ART is much better in this respect, and the performance of mobile chips has also improved a lot. Generally I don’t think this should be a big problem now. You can start to think about optimization when you actually see some performance issues.
Adam Powell03/04/2022, 2:13 PM
is a good example of an API designed for helping you with this; you get an outer block for creating things you might reuse over time and an inner block for drawing using those same object instances
Filip Wiesner03/04/2022, 2:21 PM
we've done this in the deeper compose internals so that in the common case, you don't have to go this far yourselfSame reasoning as with enums in the "old days" (enums being represented with Integers instead of an actual enum)
Adam Powell03/04/2022, 2:22 PM
Filip Wiesner03/04/2022, 2:26 PM
Anton Shilov03/04/2022, 3:46 PM