From c330ecec2b2c12eb41fff3f487c47f00dbdd685d Mon Sep 17 00:00:00 2001 From: iris-ai <4+iris-ai@noreply.localhost> Date: Thu, 17 Sep 2026 15:53:24 -0400 Subject: [PATCH] Skip inverse arithmetic for unrestricted layout validity --- core/src/ui/holds.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/src/ui/holds.rs b/core/src/ui/holds.rs index 79270f4..067ef31 100644 --- a/core/src/ui/holds.rs +++ b/core/src/ui/holds.rs @@ -52,6 +52,9 @@ impl Holds { /// allowance: inverting it is two divisions and nothing else, and the /// whole of a box maps back to itself. pub const fn through(self, len: Len) -> Self { + if self.lo.raw() == Px::MIN.raw() && self.hi.raw() == Px::MAX.raw() { + return Self::ANY; + } let rel = len.rel.raw() as i64; if rel == 0 { return Self::ANY; @@ -92,6 +95,16 @@ mod tests { use super::*; use crate::Rel; + #[test] + fn an_unrestricted_range_stays_unrestricted_through_any_length() { + for rel in [-2.0, -0.5, 0.0, 0.5, 1.0, 2.0] { + for px in [-8, 0, 8] { + let len = Len::from_parts(Rel::from_f32(rel), Px::from_int(px)); + assert_eq!(Holds::ANY.through(len), Holds::ANY); + } + } + } + #[test] fn through_reverses_a_range_for_a_negative_fraction() { // `10 - box / 2` is between 20 and 40 for boxes from -60 to -20.