From d48cf4e5ee47bd3ec61776c72dda19ac4615f04d Mon Sep 17 00:00:00 2001 From: Benoit de Chezelles Date: Sat, 3 Jul 2021 20:06:45 +0200 Subject: [PATCH] Few micro-optimizations for performance --- wezterm-gui/src/glyphcache.rs | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/wezterm-gui/src/glyphcache.rs b/wezterm-gui/src/glyphcache.rs index 7a2548db2..c056d259e 100644 --- a/wezterm-gui/src/glyphcache.rs +++ b/wezterm-gui/src/glyphcache.rs @@ -4373,24 +4373,26 @@ impl GlyphCache { let mut paint = Paint::default(); paint.set_color(tiny_skia::Color::WHITE); paint.force_hq_pipeline = true; - - let bit_index_and_dot_position = [ - (0, (0, 0)), - (1, (0, 1)), - (2, (0, 2)), - (3, (1, 0)), - (4, (1, 1)), - (5, (1, 2)), - (6, (0, 3)), - (7, (1, 3)), + paint.anti_alias = true; + let identity = Transform::identity(); + + const BIT_INDEX_AND_DOT_POSITION: [(u8, f32, f32); 8] = [ + (0, 0., 0.), + (1, 0., 1.), + (2, 0., 2.), + (3, 1., 0.), + (4, 1., 1.), + (5, 1., 2.), + (6, 0., 3.), + (7, 1., 3.), ]; - for (bit_index, (dot_pos_x, dot_pos_y)) in &bit_index_and_dot_position { + for (bit_index, dot_pos_x, dot_pos_y) in &BIT_INDEX_AND_DOT_POSITION { if dots_pattern & (1 << bit_index) == 0 { // Bit for this dot position is not set continue; } - let center_x = (*dot_pos_x as f32) * cell_width + center_offset_x; - let center_y = (*dot_pos_y as f32) * cell_height + center_offset_y; + let center_x = (*dot_pos_x) * cell_width + center_offset_x; + let center_y = (*dot_pos_y) * cell_height + center_offset_y; let path = PathBuilder::from_circle(center_x, center_y, radius) .expect("failed to create path from circle"); @@ -4399,7 +4401,7 @@ impl GlyphCache { &path, &paint, FillRule::Winding, - Transform::identity(), + identity, None, ); } -- 2.54.0