Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup some bevy_text pipeline.rs #9111

Merged
merged 1 commit into from
Aug 28, 2023

Commits on Jul 18, 2023

  1. Cleanup some bevy_text pipeline.rs

    Objective
    ------
    
    - `bevy_text/src/pipeline.rs` had some crufty code.
    
    Solution
    ------
    
    Remove the cruft.
    
    - `&mut self` argument was unused by `TextPipeline::create_text_measure`, so we replace it with a constructor `TextMeasureInfo::from_text`.
    - We also pass a `&Text` to `from_text` since there is no reason to split the struct before passing it as argument.
    - from_text also checks beforehand that every Font exist in the Assets<Font>. This allows rust to skip the drop code on the Vecs we create in the method, since there is no early exit.
    - We also remove the scaled_fonts field on `TextMeasureInfo`. This avoids an additional allocation. We can re-use the font on `fonts` instead in `compute_size`. Building a `ScaledFont` seems fairly cheap, when looking at the ab_glyph internals.
    - We also implement ToSectionText on TextMeasureSection, this let us skip creating a whole new Vec each time we call compute_size.
    - This let us remove compute_size_from_section_text, since its only purpose was to not have to allocate the Vec we just made redundant.
    - Make some immutabe `Vec<T>` into `Box<[T]>` and `String` into `Box<str>`
    
    The `ResMut<TextPipeline>` argument to  `measure_text_system` doesn't exist anymore. If you were calling this system manually, you should remove the argument.
    nicopap committed Jul 18, 2023
    Configuration menu
    Copy the full SHA
    c446236 View commit details
    Browse the repository at this point in the history