perf(anatomy): V1-2.2 skip arc spread sampling where unused

Third security review LOW: the f32 spread of an arc is sampled only
when an outline is drawn and under its vertex cap; the variants'
extremes still join the bounds.
This commit is contained in:
bchanot committed 2026-11-01 13:31:39 +01:00
1 parent 86dce16b09
commit c73415abef
2 files changed
+15 -1

No files matched your search

+6 -1
View File
@@ -579,6 +579,11 @@ impl Pen {
moved(0.0, 0.0, (more, same)),
moved(0.0, 0.0, (same, more)),
];
// The bounds need the extremes alone; an outline past its cap is refused anyway.
let sampled = self
.flat
.as_ref()
.is_some_and(|flat| !flat.outline.overflow);
let mut spread = 0.0_f64;
for variant in &variants {
let other = Ellipse::through(from, variant);
@@ -587,7 +592,7 @@ impl Pen {
self.add(other.at(angle));
}
}
for i in 0..=SPREAD_SAMPLES {
for i in (0..=SPREAD_SAMPLES).filter(|_| sampled) {
let t = f64::from(i) / f64::from(SPREAD_SAMPLES);
let here = ellipse.at(ellipse.start + ellipse.sweep * t);
let there = other.at(other.start + other.sweep * t);