Skip to content

Fix gpu_cache PGlyphSpec Ord,Eq implementations

Jeremy Soller requested to merge alexheretic:pglyphspec-ord-panic into master

Created by: alexheretic

Fix rare glyph ordering panic in gpu cache code caused by partial_cmp unwrap. I used crate ordered-float to provide Ord implementations for floats, any other f32 -> Ord functionality would do too.

It's worth noting I produced this panic in the wild, so this isn't a theoretical or pedantic fix.

...It also seems this is an accidental totally deliberate optimisation. When checking for regressions I noticed a speedup in benchmarks. The p1 results are a nice speedup outside of the benchmark error.

 name                                                    control.stdout ns/iter  change.stdout ns/iter  diff ns/iter   diff %  speedup 
 gpu_cache::cache_bench_tests::cache_bench_tolerance_1   3,317,397               3,096,244                  -221,153   -6.67%   x 1.07 
 gpu_cache::cache_bench_tests::cache_bench_tolerance_p1  6,931,439               5,391,674                -1,539,765  -22.21%   x 1.29 

Merge request reports