Skip to content

Commit

Permalink
Minor TextPipeline cleanup (#17274)
Browse files Browse the repository at this point in the history
# Objective

Both `set_metrics` and `set_size` **can** trigger text re-layout and
re-shaping, if the values provided are different form what is already in
the `Buffer`.

## Solution

Combine the `set_metrics` and `set_size` calls.

This might be a small optimization in some situations, maybe when both
font size and text bounds change in the same frame, or when spawning new
text.

I did measure a ~500 microsecond improvement in `text_system` for
`many_buttons --respawn`, but that may have just been noise.
  • Loading branch information
rparrett authored Jan 10, 2025
1 parent 4bca7f1 commit ec795a2
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions crates/bevy_text/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ impl TextPipeline {

// Update the buffer.
let buffer = &mut computed.buffer;
buffer.set_metrics(font_system, metrics);
buffer.set_size(font_system, bounds.width, bounds.height);
buffer.set_metrics_and_size(font_system, metrics, bounds.width, bounds.height);

buffer.set_wrap(
font_system,
Expand Down

0 comments on commit ec795a2

Please sign in to comment.