Do not multiply by a part of nothing

`lerp` is `a + (b - a) * f`, and `b - a` is nothing often enough to be worth
asking: a box with the same pixels at both ends of an axis, a span with no
fraction of one, a part of a subtree whose box did not move on that axis.
`Fixed::scaled` is `mul` that answers a zero receiver without widening to
`i64`, rounding and narrowing back, and `lerp` uses it -- so every lerp in
layout gets it rather than the two places that were about to grow their own
comparison.

`many` over 500 frames: 1,705,786,553 instructions to 1,657,571,216, and
638.9M cycles against 657.9M, averaged over four runs each.

Checked: fmt, clippy, 105 tests, all five shrinker cases at 300 seeds, and
`tabs`, `text`, `random`, `minimal` and `view` byte-identical at 1920x1200.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
iris-aiandClaude Opus 5 committed 2026-09-16 14:01:52 -04:00
1 parent d75a1e2129
commit 4cbb242a5d
2 files changed
+14 -4

No files matched your search

+3 -3
View File
@@ -1146,9 +1146,9 @@ impl AxisRemap {
true => offset,
false => offset / scale.extent,
};
let from_px = scale.from_px + scale.from_px_span.mul(fraction);
let to_rel = scale.to_rel + scale.to_rel_span.mul(fraction);
let to_px = scale.to_px + scale.to_px_span.mul(fraction);
let from_px = scale.from_px + scale.from_px_span.scaled(fraction);
let to_rel = scale.to_rel + scale.to_rel_span.scaled(fraction);
let to_px = scale.to_px + scale.to_px_span.scaled(fraction);
Len::from_parts(to_rel, scalar.px - from_px + to_px)
}
}