Description
Currently, a RichText
(and also LayoutJob
) holds a String
to store the data. I propose we change these to take a new enum type, with Single(&str)
, Multiple(&[&str])
and an Owned(String)
variants. The lifetimes should essentially be generic; so users can pass any string they want, without creating a new string. This would get rid of creating a new string 60 times per second for all labels / buttons etc. which could add up a lot if there is a lot of different widgets that have text. RichText
would essentially use the Single
variant. The Multiple
variant is for the macro mentioned in LayoutJob
docs, it should allow the user to style text without needing to create a new string.
The downside is that this requires putting lifetimes everywhere, which can be a PITA to look at / work with sometimes. The lifetimes wouldn't be visible to a user most of the time, since widgets are created and used immediately and not stored. To make sure this is worth the effort, this should be implemented first and then benchmarked in different scenarios. I may try to implement this later, but I'm putting this out there so that I don't forget it.