Move matrix layout logic's early exit upward (#4583)

This commit is contained in:
Leedehai 2024-07-20 08:51:51 -04:00 committed by GitHub
parent 0c37a2c233
commit 96d456e267
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -458,6 +458,12 @@ fn layout_mat_body(
gap: Axes<Rel<Abs>>,
span: Span,
) -> SourceResult<Frame> {
let ncols = rows.first().map_or(0, |row| row.len());
let nrows = rows.len();
if ncols == 0 || nrows == 0 {
return Ok(Frame::soft(Size::zero()));
}
let gap = gap.zip_map(ctx.regions.base(), Rel::relative_to);
let half_gap = gap * 0.5;
@ -483,12 +489,6 @@ fn layout_mat_body(
_ => (AugmentOffsets::default(), AugmentOffsets::default(), default_stroke),
};
let ncols = rows.first().map_or(0, |row| row.len());
let nrows = rows.len();
if ncols == 0 || nrows == 0 {
return Ok(Frame::soft(Size::zero()));
}
// Before the full matrix body can be laid out, the
// individual cells must first be independently laid out
// so we can ensure alignment across rows and columns.