Skip to content

Commit

Permalink
Rename num_font_atlases to len. (#9879)
Browse files Browse the repository at this point in the history
# Objective

Rename the `num_font_atlases` method of `FontAtlasSet` to `len`.

All the function does is return the number of entries in its hashmap and
the unnatural naming only makes it harder to discover.

---

## Changelog

* Renamed the `num_font_atlases` method of `FontAtlasSet` to `len`.

## Migration Guide

The `num_font_atlases` method of `FontAtlasSet` has been renamed to
`len`.
  • Loading branch information
ickshonpe authored Sep 20, 2023
1 parent e07c427 commit 9873c97
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion crates/bevy_text/src/font_atlas_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,13 @@ impl FontAtlasSet {
})
}

pub fn num_font_atlases(&self) -> usize {
/// Returns the number of font atlases in this set
pub fn len(&self) -> usize {
self.font_atlases.len()
}

/// Returns `true` if the font atlas set contains no elements
pub fn is_empty(&self) -> bool {
self.font_atlases.is_empty()
}
}
2 changes: 1 addition & 1 deletion crates/bevy_text/src/glyph_brush.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl GlyphBrush {

if !text_settings.allow_dynamic_font_size
&& !font_atlas_warning.warned
&& font_atlas_set.num_font_atlases() > text_settings.max_font_atlases.get()
&& font_atlas_set.len() > text_settings.max_font_atlases.get()
{
warn!("warning[B0005]: Number of font atlases has exceeded the maximum of {}. Performance and memory usage may suffer.", text_settings.max_font_atlases.get());
font_atlas_warning.warned = true;
Expand Down

0 comments on commit 9873c97

Please sign in to comment.