fontations icon indicating copy to clipboard operation
fontations copied to clipboard

[Skrifa] Minor speedup to iup mechanism

Open behdad opened this issue 7 months ago • 2 comments

PoC:

diff --git a/skrifa/src/outline/glyf/deltas.rs b/skrifa/src/outline/glyf/deltas.rs
index c59021a7..426cd86b 100644
--- a/skrifa/src/outline/glyf/deltas.rs
+++ b/skrifa/src/outline/glyf/deltas.rs
@@ -265,6 +265,18 @@ where
                     } else {
                         D::zeroed()
                     };
+                    if scale == D::zeroed() {
+                        let d1 = out1 - in1;
+                        for (point, out_point) in self
+                            .points
+                            .get(range.clone())?
+                            .iter()
+                            .zip(self.out_points.get_mut(range.clone())?)
+                        {
+                            out_point.$coord = d1 + D::from(point.$coord);
+                        }
+                        return Some(());
+                    }
                     let d1 = out1 - in1;
                     let d2 = out2 - in2;
                     for (point, out_point) in self

I measured 1.5% with mega var font.

behdad avatar May 29 '25 18:05 behdad

Nice!

Nit: looks like you always do let d1 = out1 - in1;, could do it once ahead of the if

rsheeter avatar May 29 '25 18:05 rsheeter

Yeah, not supposed to be the final patch. I let Chad oxidize it.

behdad avatar May 29 '25 18:05 behdad