diff --git a/src/route_d.rs b/src/route_d.rs index 20a6807..2bb378a 100755 --- a/src/route_d.rs +++ b/src/route_d.rs @@ -14034,15 +14034,14 @@ fn build_document_with_labels( base_units[index].space_shrink += below_display.2; } } - if has_title_bars(geometry) { - // The class's title block starts with a top rule and vskip. The page - // builder discards glue before the first unit, so use an invisible - // rule as the spacer instead. - base_units.insert(0, Unit::rule(u64::MAX, 0, 2 * SCALE)); - } - let mut units: Vec = Vec::with_capacity(base_units.len()); + let title_spacer = has_title_bars(geometry).then(|| Unit::rule(u64::MAX, 0, 2 * SCALE)); + let mut units: Vec = + Vec::with_capacity(base_units.len() + usize::from(title_spacer.is_some())); let mut unit_for_paragraph = Vec::with_capacity(paragraphs.len()); let mut footnote_count = 0usize; + if let Some(spacer) = title_spacer { + units.push(spacer); + } for (paragraph, unit) in paragraphs.iter().zip(base_units) { unit_for_paragraph.push(units.len()); units.push(unit);