From 5f28feef1fd03d3f19c801059aa2e64fb0facaf7 Mon Sep 17 00:00:00 2001 From: Imbris Date: Mon, 14 Aug 2023 00:54:50 -0400 Subject: [PATCH] Move variables down that are only used when creating LayoutLines and replaced used of push_line bool with checking is layout_lines is empty --- src/shape.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/shape.rs b/src/shape.rs index e2c0871..9144b18 100644 --- a/src/shape.rs +++ b/src/shape.rs @@ -875,17 +875,6 @@ impl ShapeLine { align: Option, layout_lines: &mut Vec, ) { - let align = align.unwrap_or({ - if self.rtl { - Align::Right - } else { - Align::Left - } - }); - - // This is used to create a visual line for empty lines (e.g. lines with only a ) - let mut push_line = true; - // For each visual line a list of (span index, and range of words in that span) // Note that a BiDi visual line could have multiple spans or parts of them // let mut vl_range_of_spans = Vec::with_capacity(1); @@ -1149,6 +1138,14 @@ impl ShapeLine { } // Create the LayoutLines using the ranges inside visual lines + let align = align.unwrap_or({ + if self.rtl { + Align::Right + } else { + Align::Left + } + }); + let start_x = if self.rtl { line_width } else { 0.0 }; let number_of_visual_lines = visual_lines.len(); @@ -1264,10 +1261,10 @@ impl ShapeLine { max_descent: max_descent * font_size, glyphs, }); - push_line = false; } - if push_line { + // This is used to create a visual line for empty lines (e.g. lines with only a ) + if layout_lines.is_empty() { layout_lines.push(LayoutLine { w: 0.0, max_ascent: 0.0,