diff options
| author | Leedehai <18319900+Leedehai@users.noreply.github.com> | 2024-07-20 08:51:51 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-20 12:51:51 +0000 |
| commit | 96d456e2672c05f0b9c042fb481b1748c013a63d (patch) | |
| tree | fbf2957299dd86a5ae5660e39455e0e0c0808eec | |
| parent | 0c37a2c2334afb6947f265e00bded0fe75be6434 (diff) | |
Move matrix layout logic's early exit upward (#4583)
| -rw-r--r-- | crates/typst/src/math/matrix.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/crates/typst/src/math/matrix.rs b/crates/typst/src/math/matrix.rs index 34e0611a..95164e82 100644 --- a/crates/typst/src/math/matrix.rs +++ b/crates/typst/src/math/matrix.rs @@ -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. |
