I make extensive use of `TextMeasurer` in my compo...
# compose
m
I make extensive use of
TextMeasurer
in my composables. Should I be passing this around as an argument (many composables) or just using
rememberTextMeasurer
where needed?
h
It depends on how you are utilizing the internal cache of TextMeasurer. Every
rememberTextMeasurer
would initialize a new
TextMeasurer
for you with a separate cache. If you are not using the cache (as in specifying
cacheSize
as 0) then you can safely pass the
TextMeasurer
to other composables and save yourself extra few allocations. However, if you are taking advantage of the internal cache, then all your
measure
calls in all the different composables would be hitting the same cache. If you do not have a sufficiently large sized cache, then you may run into lots of cache misses which would be a more serious problem for performance. In that case I'd recommend you to just use
rememberTextMeasurer
in each Composable.
thank you color 1