Refactor: BLF Remove Size Parameter from blf_glyph_cache_find

The "size" parameter here is unnecessary in that we are passing the
font itself and the function is only ever called (the once) with
font->size. The parameter is also misleading in that you could assume
that the cache is matching only the font size when it actually matches
multiple attributes, including size. Size isn't special here.

Pull Request: https://projects.blender.org/blender/blender/pulls/118469
This commit is contained in:
Harley Acheson
2024-02-19 20:31:53 +01:00
committed by Harley Acheson
parent b13c7941ce
commit 783e565110

View File

@@ -75,10 +75,10 @@ static float from_16dot16(FT_Fixed value)
/** \name Glyph Cache
* \{ */
static GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, const float size)
static GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font)
{
for (std::unique_ptr<GlyphCacheBLF> &gc : font->cache) {
if (gc->size == size && (gc->bold == ((font->flags & BLF_BOLD) != 0)) &&
if (gc->size == font->size && (gc->bold == ((font->flags & BLF_BOLD) != 0)) &&
(gc->italic == ((font->flags & BLF_ITALIC) != 0)) &&
(gc->char_weight == font->char_weight) && (gc->char_slant == font->char_slant) &&
(gc->char_width == font->char_width) && (gc->char_spacing == font->char_spacing))
@@ -130,7 +130,7 @@ GlyphCacheBLF *blf_glyph_cache_acquire(FontBLF *font)
{
font->glyph_cache_mutex.lock();
GlyphCacheBLF *gc = blf_glyph_cache_find(font, font->size);
GlyphCacheBLF *gc = blf_glyph_cache_find(font);
if (!gc) {
gc = blf_glyph_cache_new(font);