Repository: alacritty/alacritty
File: alacritty/src/renderer/mod.rs (Rust)

Code before:
        let (regular, bold, italic, bold_italic) =
            Self::compute_font_keys(&font, &mut self.rasterizer)?;

        self.rasterizer.get_glyph(GlyphKey { font_key: regular, c: 'm', size: font.size })?;
        let metrics = self.rasterizer.metrics(regular, font.size)?;

        info!("Font size changed to {:?} with DPR of {}", font.size, dpr);

        self.font_size = font.size;
        self.font_key = regular;
        self.bold_key = bold;
        self.italic_key = italic;
        self.bold_italic_key = bold_italic;
        self.metrics = metrics;

        self.clear_glyph_cache(loader);

        Ok(())
    }

    pub fn font_metrics(&self) -> font::Metrics {
        self.metrics
    }

    fn load_common_glyphs<L: LoadGlyph>(&mut self, loader: &mut L) {
        self.load_glyphs_for_font(self.font_key, loader);
        self.load_glyphs_for_font(self.bold_italic_key, loader);
        self.load_glyphs_for_font(self.italic_key, loader);
        self.load_glyphs_for_font(self.bold_italic_key, loader);
    }

    // Calculate font metrics without access to a glyph cache
    pub fn static_metrics(font: Font, dpr: f64) -> Result<font::Metrics, font::Error> {
        let mut rasterizer = font::Rasterizer::new(dpr as f32, font.use_thin_strokes())?;
        let regular_desc =
            GlyphCache::make_desc(&font.normal(), font::Slant::Normal, font::Weight::Normal);
        let regular = rasterizer.load_font(&regular_desc, font.size)?;
        rasterizer.get_glyph(GlyphKey { font_key: regular, c: 'm', size: font.size })?;

        rasterizer.metrics(regular, font.size)
    }

    pub fn calculate_dimensions<C>(
        config: &Config<C>,
        dpr: f64,
        cell_width: f32,
        cell_height: f32,
    ) -> Option<(u32, u32)> {
        let dimensions = config.window.dimensions;

        if dimensions.columns_u32() == 0

Review comment (suggestion):
```suggestion
    /// Prefetch glyphs that are almost guaranteed to be loaded anyways.
    fn load_common_glyphs<L: LoadGlyph>(&mut self, loader: &mut L) {
```

Code after:
        let (regular, bold, italic, bold_italic) =
            Self::compute_font_keys(&font, &mut self.rasterizer)?;

        self.rasterizer.get_glyph(GlyphKey { font_key: regular, c: 'm', size: font.size })?;
        let metrics = self.rasterizer.metrics(regular, font.size)?;

        info!("Font size changed to {:?} with DPR of {}", font.size, dpr);

        self.font_size = font.size;
        self.font_key = regular;
        self.bold_key = bold;
        self.italic_key = italic;
        self.bold_italic_key = bold_italic;
        self.metrics = metrics;

        self.clear_glyph_cache(loader);

        Ok(())
    }

    pub fn font_metrics(&self) -> font::Metrics {
        self.metrics
    }

    /// Prefetch glyphs that are almost guaranteed to be loaded anyways.
    fn load_common_glyphs<L: LoadGlyph>(&mut self, loader: &mut L) {
        self.load_glyphs_for_font(self.font_key, loader);
        self.load_glyphs_for_font(self.bold_italic_key, loader);
        self.load_glyphs_for_font(self.italic_key, loader);
        self.load_glyphs_for_font(self.bold_italic_key, loader);
    }

    // Calculate font metrics without access to a glyph cache
    pub fn static_metrics(font: Font, dpr: f64) -> Result<font::Metrics, font::Error> {
        let mut rasterizer = font::Rasterizer::new(dpr as f32, font.use_thin_strokes())?;
        let regular_desc =
            GlyphCache::make_desc(&font.normal(), font::Slant::Normal, font::Weight::Normal);
        let regular = rasterizer.load_font(&regular_desc, font.size)?;
        rasterizer.get_glyph(GlyphKey { font_key: regular, c: 'm', size: font.size })?;

        rasterizer.metrics(regular, font.size)
    }

    pub fn calculate_dimensions<C>(
        config: &Config<C>,
        dpr: f64,
        cell_width: f32,
        cell_height: f32,
    ) -> Option<(u32, u32)> {
        let dimensions = config.window.dimensions;