Remove float comparisons with ==
We do some float comparisons with ==
, which is wrong in some cases, and the clippy lints rightfully complain:
warning: strict comparison of f32 or f64
--> rsvg_internals/src/path_builder.rs:127:24
|
127 | if x1 == x2 && y1 == y2 {
warning: strict comparison of f32 or f64
--> rsvg_internals/src/pattern.rs:417:27
|
417 | if scwscale != 1.0 || schscale != 1.0 {
In the first case (arbitrary x1 == x2
), see this issue against float-cmp, about comparing floats against (possibly) zero. We can experiment with having a local ApproxEqEpsilonOrUlps
trait, with the epsilon adjusted to the smallest fixed-point number that Cairo can represent. Or something like that: each comparison needs to be considered independently.
In the second case (scwscale != 1.0
), I think we can just use float_cmp::ApproxEqUlps
since we are not comparing against zero.