From f0cc8cd69626f960582a97cc29daa03f9099d71b Mon Sep 17 00:00:00 2001 From: exoticus <56480961+exoticus@users.noreply.github.com> Date: Mon, 13 Apr 2020 21:27:34 +0200 Subject: [PATCH] better than repetitive if statements --- src/renderer/caching_shaper.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/renderer/caching_shaper.rs b/src/renderer/caching_shaper.rs index c094cbd..56d5512 100644 --- a/src/renderer/caching_shaper.rs +++ b/src/renderer/caching_shaper.rs @@ -176,20 +176,16 @@ pub fn build_collection_by_font_name( } } - if let Some(family) = loader.get_or_load(SYSTEM_SYMBOL_FONT, false) { - collection.add_family(family.to_family()); - } - - if let Some(family) = loader.get_or_load(SYSTEM_EMOJI_FONT, false) { - collection.add_family(family.to_family()); - } - - if let Some(family) = loader.get_or_load(EXTRA_SYMBOL_FONT, true) { - collection.add_family(family.to_family()); + for font in &[SYSTEM_SYMBOL_FONT, SYSTEM_EMOJI_FONT] { + if let Some(family) = loader.get_or_load(font, false) { + collection.add_family(family.to_family()); + } } - if let Some(family) = loader.get_or_load(MISSING_GLYPH_FONT, true) { - collection.add_family(family.to_family()); + for font in &[EXTRA_SYMBOL_FONT, MISSING_GLYPH_FONT] { + if let Some(family) = loader.get_or_load(font, true) { + collection.add_family(family.to_family()); + } } collection