Skip to main content

shared_plain_annotated_string

Function shared_plain_annotated_string 

Source
pub fn shared_plain_annotated_string(text: &str) -> Rc<AnnotatedString>
Expand description

Returns the shared AnnotatedString for a plain, style-free string, reusing the copy made on an earlier frame when the content matches.

Draw scopes lower every draw_text* call through an AnnotatedString on every frame — once to measure and once to emit — and a HUD label or score counter has the same characters frame after frame. Without this pool each pass re-copied a string it had copied the frame before, only to hash it and hit a layout cache that is keyed by content anyway. Entries are verified by content on hit, so a hash collision costs a fresh copy, never wrong text. The pool clears itself when full; a live scene re-warms within one frame.