Apply suggestions from code review

Co-authored-by: Laurenz <laurmaedje@gmail.com>
This commit is contained in:
Martin 2021-06-27 17:08:40 +02:00 committed by GitHub
parent 6b6cdae7ce
commit 57bd3e23c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 7 deletions

View File

@ -108,7 +108,7 @@ impl Length {
self.raw + 1e-6 >= other.raw self.raw + 1e-6 >= other.raw
} }
/// Compares to lengths for whether they are approximately equal. /// Compares two lengths for whether they are approximately equal.
pub fn approx_eq(self, other: Self) -> bool { pub fn approx_eq(self, other: Self) -> bool {
self == other || (self - other).to_raw().abs() < 1e-6 self == other || (self - other).to_raw().abs() < 1e-6
} }

View File

@ -101,7 +101,7 @@ pub struct FramesEntry {
/// How nested the frame was in the context is was originally appearing in. /// How nested the frame was in the context is was originally appearing in.
pub level: usize, pub level: usize,
/// How much the element was accessed during the last five compilations, the /// How much the element was accessed during the last five compilations, the
/// most current one being the last element. `None` variants indicate that /// most recent one being the last element. `None` variants indicate that
/// the element is younger than five compilations. /// the element is younger than five compilations.
temperature: [Option<usize>; 5], temperature: [Option<usize>; 5],
} }

View File

@ -219,12 +219,18 @@ impl<'a> ParLayouter<'a> {
stack.finish_region(ctx); stack.finish_region(ctx);
} }
if !stack.regions.current.height.fits(line.size.height) // If the line does not fit vertically, we start a new region.
&& stack.regions.in_full_last() while !stack.regions.current.height.fits(line.size.height) {
{ if stack.regions.in_full_last() {
stack.overflowing = true; stack.overflowing = true;
break;
} }
stack.constraints.max.vertical.set_min(
stack.full.height - stack.regions.current.height + line.size.height,
);
stack.finish_region(ctx);
}
// If the line does not fit horizontally or we have a mandatory // If the line does not fit horizontally or we have a mandatory
// line break (i.e. due to "\n"), we push the line into the // line break (i.e. due to "\n"), we push the line into the
// stack. // stack.