diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-10-12 17:29:01 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-10-12 17:29:01 +0200 |
| commit | 5243878d810d4817c81acc9ae346d46757fcf602 (patch) | |
| tree | 4a8be00ab7262030a6ba8c6638b969a03ac1d9b5 /src/layout/par.rs | |
| parent | 38157b0e0cbab22dc3f5fa5cc66d9b673a18a55b (diff) | |
Less vecs in layouting ⚡
Diffstat (limited to 'src/layout/par.rs')
| -rw-r--r-- | src/layout/par.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/layout/par.rs b/src/layout/par.rs index e77bb4e7..ad71cffc 100644 --- a/src/layout/par.rs +++ b/src/layout/par.rs @@ -19,17 +19,20 @@ pub struct Par { } impl Layout for Par { - fn layout(&self, ctx: &mut LayoutContext, areas: &Areas) -> Vec<Layouted> { + fn layout(&self, ctx: &mut LayoutContext, areas: &Areas) -> Layouted { let mut layouter = ParLayouter::new(self, areas.clone()); for child in &self.children { - for layouted in child.layout(ctx, &layouter.areas) { - match layouted { - Layouted::Spacing(spacing) => layouter.spacing(spacing), - Layouted::Boxed(boxed, aligns) => layouter.boxed(boxed, aligns.cross), + match child.layout(ctx, &layouter.areas) { + Layouted::Spacing(spacing) => layouter.spacing(spacing), + Layouted::Boxed(boxed, aligns) => layouter.boxed(boxed, aligns.cross), + Layouted::Boxes(boxes) => { + for (boxed, aligns) in boxes { + layouter.boxed(boxed, aligns.cross); + } } } } - layouter.finish() + Layouted::Boxes(layouter.finish()) } } @@ -45,7 +48,7 @@ struct ParLayouter<'a> { cross: SpecAxis, dirs: Gen<Dir>, areas: Areas, - layouted: Vec<Layouted>, + layouted: Vec<(BoxLayout, Gen<Align>)>, lines: Vec<(Length, BoxLayout, Align)>, lines_size: Gen<Length>, run: Vec<(Length, BoxLayout, Align)>, @@ -169,13 +172,13 @@ impl<'a> ParLayouter<'a> { output.push_layout(pos, run); } - self.layouted.push(Layouted::Boxed(output, self.par.aligns)); + self.layouted.push((output, self.par.aligns)); self.areas.next(); self.lines_size = Gen::ZERO; } - fn finish(mut self) -> Vec<Layouted> { + fn finish(mut self) -> Vec<(BoxLayout, Gen<Align>)> { self.finish_run(); self.finish_area(); self.layouted |
