[librsvg] Update float-cmp



commit 2478d1142eab68ec9a5664f9b8919075e5717c86
Author: Bastien Orivel <eijebong bananium fr>
Date:   Sun Jul 21 13:34:29 2019 +0200

    Update float-cmp
    
    I chose to change the signature of approx_eq_cairo to take a `f64` instead
    of a `&f64` to avoid having to dereference it in the function as it looks
    better when calling that method.

 Cargo.lock                           |  6 +++---
 rsvg_internals/Cargo.toml            |  2 +-
 rsvg_internals/src/angle.rs          |  2 +-
 rsvg_internals/src/aspect_ratio.rs   |  4 ++--
 rsvg_internals/src/filters/image.rs  |  2 +-
 rsvg_internals/src/float_eq_cairo.rs | 28 ++++++++++++++--------------
 rsvg_internals/src/image.rs          |  2 +-
 rsvg_internals/src/marker.rs         |  8 ++++----
 rsvg_internals/src/path_builder.rs   |  2 +-
 rsvg_internals/src/pattern.rs        |  2 +-
 rsvg_internals/src/rect.rs           |  2 +-
 rsvg_internals/src/structure.rs      |  2 +-
 rsvg_internals/src/text.rs           |  2 +-
 rsvg_internals/src/transform.rs      | 12 ++++++------
 14 files changed, 38 insertions(+), 38 deletions(-)
---
diff --git a/Cargo.lock b/Cargo.lock
index 7861f2fe..cff6fa50 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -337,7 +337,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index";
 
 [[package]]
 name = "float-cmp"
-version = "0.4.0"
+version = "0.5.2"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 dependencies = [
  "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -935,7 +935,7 @@ dependencies = [
  "data-url 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "downcast-rs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
- "float-cmp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "float-cmp 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "gdk-pixbuf 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "gdk-pixbuf-sys 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "gio 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1248,7 +1248,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index";
 "checksum encoding-index-singlebyte 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = 
"3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a"
 "checksum encoding-index-tradchinese 1.20141219.5 (registry+https://github.com/rust-lang/crates.io-index)" = 
"fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18"
 "checksum encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = 
"a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569"
-"checksum float-cmp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = 
"134a8fa843d80a51a5b77d36d42bc2def9edcb0262c914861d08129fd1926600"
+"checksum float-cmp 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = 
"7ef4eee449a2818084dad09f4fcd6e6e8932c482d8d94298493226782bb45b5e"
 "checksum fragile 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = 
"05f8140122fa0d5dcb9fc8627cfce2b37cc1500f752636d46ea28bc26785c2f9"
 "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = 
"a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
 "checksum futf 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = 
"7c9c1ce3fa9336301af935ab852c437817d14cd33690446569392e65170aac3b"
diff --git a/rsvg_internals/Cargo.toml b/rsvg_internals/Cargo.toml
index 5cd9c88e..26f860e9 100644
--- a/rsvg_internals/Cargo.toml
+++ b/rsvg_internals/Cargo.toml
@@ -25,7 +25,7 @@ cssparser = "0.25.5"
 data-url = "0.1"
 downcast-rs = "^1.0.0"
 encoding = "0.2.33"
-float-cmp = "= 0.4.0"
+float-cmp = "0.5.2"
 gdk-pixbuf = "0.7.0"
 gdk-pixbuf-sys = "0.9.0"
 gio = { version="0.7.0", features=["v2_48"] } # per configure.ac
diff --git a/rsvg_internals/src/angle.rs b/rsvg_internals/src/angle.rs
index 2f75ad56..4dbd064f 100644
--- a/rsvg_internals/src/angle.rs
+++ b/rsvg_internals/src/angle.rs
@@ -132,7 +132,7 @@ mod tests {
         let i = Angle::from_vector(incoming_vx, incoming_vy);
         let o = Angle::from_vector(outgoing_vx, outgoing_vy);
         let bisected = i.bisect(o);
-        assert!(expected.approx_eq(&bisected.radians(), 2.0 * PI * f64::EPSILON, 1));
+        assert!(expected.approx_eq(bisected.radians(), (2.0 * PI * f64::EPSILON, 1)));
     }
 
     #[test]
diff --git a/rsvg_internals/src/aspect_ratio.rs b/rsvg_internals/src/aspect_ratio.rs
index a4df07b6..32294b35 100644
--- a/rsvg_internals/src/aspect_ratio.rs
+++ b/rsvg_internals/src/aspect_ratio.rs
@@ -161,14 +161,14 @@ impl AspectRatio {
         // https://www.w3.org/TR/SVG/struct.html#ImageElementWidthAttribute
         // https://www.w3.org/TR/SVG/painting.html#MarkerWidthAttribute
 
-        if viewport.width.approx_eq_cairo(&0.0) || viewport.height.approx_eq_cairo(&0.0) {
+        if viewport.width.approx_eq_cairo(0.0) || viewport.height.approx_eq_cairo(0.0) {
             return None;
         }
 
         // the preserveAspectRatio attribute is only used if viewBox is specified
         // https://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute
         if let Some(vbox) = vbox {
-            if vbox.width.approx_eq_cairo(&0.0) || vbox.height.approx_eq_cairo(&0.0) {
+            if vbox.width.approx_eq_cairo(0.0) || vbox.height.approx_eq_cairo(0.0) {
                 // Width or height of 0 for the viewBox disables rendering of the element
                 // https://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute
                 None
diff --git a/rsvg_internals/src/filters/image.rs b/rsvg_internals/src/filters/image.rs
index 8adf9ed8..c0ca11c2 100644
--- a/rsvg_internals/src/filters/image.rs
+++ b/rsvg_internals/src/filters/image.rs
@@ -141,7 +141,7 @@ impl Image {
             ),
         );
 
-        if w.approx_eq_cairo(&0.0) || h.approx_eq_cairo(&0.0) {
+        if w.approx_eq_cairo(0.0) || h.approx_eq_cairo(0.0) {
             return Ok(output_surface);
         }
 
diff --git a/rsvg_internals/src/float_eq_cairo.rs b/rsvg_internals/src/float_eq_cairo.rs
index 4d6f19f6..0725d743 100644
--- a/rsvg_internals/src/float_eq_cairo.rs
+++ b/rsvg_internals/src/float_eq_cairo.rs
@@ -53,13 +53,13 @@ impl FixedEqCairo for f64 {
 /// and finally allow a difference of 1 unit-in-the-last-place (ULP)
 /// for very large f64 values.
 pub trait ApproxEqCairo: ApproxEq {
-    fn approx_eq_cairo(&self, other: &Self) -> bool;
+    fn approx_eq_cairo(self, other: Self) -> bool;
 }
 
 impl ApproxEqCairo for f64 {
-    fn approx_eq_cairo(&self, other: &f64) -> bool {
+    fn approx_eq_cairo(self, other: f64) -> bool {
         let cairo_smallest_fraction = 1.0 / f64::from(1 << CAIRO_FIXED_FRAC_BITS);
-        self.approx_eq(other, cairo_smallest_fraction, 1)
+        self.approx_eq(other, (cairo_smallest_fraction, 1))
     }
 }
 
@@ -67,7 +67,7 @@ impl ApproxEqCairo for f64 {
 #[macro_export]
 macro_rules! assert_approx_eq_cairo {
     ($left:expr, $right:expr) => {{
-        match (&$left, &$right) {
+        match ($left, $right) {
             (l, r) => {
                 if !l.approx_eq_cairo(r) {
                     panic!(
@@ -98,28 +98,28 @@ mod tests {
     #[test]
     fn numbers_approx_equal() {
         // 0 == 1/256 - cairo can represent it, so not equal
-        assert!(!0.0_f64.approx_eq_cairo(&0.00390635_f64));
+        assert!(!0.0_f64.approx_eq_cairo(0.00390635_f64));
 
         // 1 == 1 + 1/256 - cairo can represent it, so not equal
-        assert!(!1.0_f64.approx_eq_cairo(&1.00390635_f64));
+        assert!(!1.0_f64.approx_eq_cairo(1.00390635_f64));
 
         // 0 == 1/256 - cairo can represent it, so not equal
-        assert!(!0.0_f64.approx_eq_cairo(&-0.00390635_f64));
+        assert!(!0.0_f64.approx_eq_cairo(-0.00390635_f64));
 
         // 1 == 1 - 1/256 - cairo can represent it, so not equal
-        assert!(!1.0_f64.approx_eq_cairo(&0.99609365_f64));
+        assert!(!1.0_f64.approx_eq_cairo(0.99609365_f64));
 
         // 0 == 1/512 - cairo approximates to 0, so equal
-        assert!(0.0_f64.approx_eq_cairo(&0.001953125_f64));
+        assert!(0.0_f64.approx_eq_cairo(0.001953125_f64));
 
         // 1 == 1 + 1/512 - cairo approximates to 1, so equal
-        assert!(1.0_f64.approx_eq_cairo(&1.001953125_f64));
+        assert!(1.0_f64.approx_eq_cairo(1.001953125_f64));
 
         // 0 == -1/512 - cairo approximates to 0, so equal
-        assert!(0.0_f64.approx_eq_cairo(&-0.001953125_f64));
+        assert!(0.0_f64.approx_eq_cairo(-0.001953125_f64));
 
         // 1 == 1 - 1/512 - cairo approximates to 1, so equal
-        assert!(1.0_f64.approx_eq_cairo(&0.998046875_f64));
+        assert!(1.0_f64.approx_eq_cairo(0.998046875_f64));
 
         // This is 2^53 compared to (2^53 + 2).  When represented as
         // f64, they are 1 unit-in-the-last-place (ULP) away from each
@@ -135,8 +135,8 @@ mod tests {
         //
         // In the second assertion, we compare 2^53 with (2^53 + 4).  Those are
         // 2 ULPs away, and we don't consider them equal.
-        assert!(9_007_199_254_740_992.0.approx_eq_cairo(&9_007_199_254_740_994.0));
-        assert!(!9_007_199_254_740_992.0.approx_eq_cairo(&9_007_199_254_740_996.0));
+        assert!(9_007_199_254_740_992.0.approx_eq_cairo(9_007_199_254_740_994.0));
+        assert!(!9_007_199_254_740_992.0.approx_eq_cairo(9_007_199_254_740_996.0));
     }
 
     #[test]
diff --git a/rsvg_internals/src/image.rs b/rsvg_internals/src/image.rs
index 2e844039..ef86cd3d 100644
--- a/rsvg_internals/src/image.rs
+++ b/rsvg_internals/src/image.rs
@@ -74,7 +74,7 @@ impl NodeTrait for NodeImage {
         let w = self.w.normalize(values, &params);
         let h = self.h.normalize(values, &params);
 
-        if w.approx_eq_cairo(&0.0) || h.approx_eq_cairo(&0.0) {
+        if w.approx_eq_cairo(0.0) || h.approx_eq_cairo(0.0) {
             return Ok(());
         }
 
diff --git a/rsvg_internals/src/marker.rs b/rsvg_internals/src/marker.rs
index fe39b9f6..6a75fc65 100644
--- a/rsvg_internals/src/marker.rs
+++ b/rsvg_internals/src/marker.rs
@@ -133,7 +133,7 @@ impl NodeMarker {
         let marker_width = self.width.normalize(&values, &params);
         let marker_height = self.height.normalize(&values, &params);
 
-        if marker_width.approx_eq_cairo(&0.0) || marker_height.approx_eq_cairo(&0.0) {
+        if marker_width.approx_eq_cairo(0.0) || marker_height.approx_eq_cairo(0.0) {
             // markerWidth or markerHeight set to 0 disables rendering of the element
             // https://www.w3.org/TR/SVG/painting.html#MarkerWidthAttribute
             return Ok(());
@@ -161,7 +161,7 @@ impl NodeMarker {
                     &Rectangle::new(0.0, 0.0, marker_width, marker_height),
                 );
 
-                if vbox.width.approx_eq_cairo(&0.0) || vbox.height.approx_eq_cairo(&0.0) {
+                if vbox.width.approx_eq_cairo(0.0) || vbox.height.approx_eq_cairo(0.0) {
                     return Ok(());
                 }
 
@@ -317,7 +317,7 @@ impl Segment {
 }
 
 fn points_equal(x1: f64, y1: f64, x2: f64, y2: f64) -> bool {
-    x1.approx_eq_cairo(&x2) && y1.approx_eq_cairo(&y2)
+    x1.approx_eq_cairo(x2) && y1.approx_eq_cairo(y2)
 }
 
 enum SegmentState {
@@ -647,7 +647,7 @@ pub fn render_markers_for_path_builder(
         .0
         .normalize(values, &draw_ctx.get_view_params());
 
-    if line_width.approx_eq_cairo(&0.0) {
+    if line_width.approx_eq_cairo(0.0) {
         return Ok(());
     }
 
diff --git a/rsvg_internals/src/path_builder.rs b/rsvg_internals/src/path_builder.rs
index 31165131..43316010 100644
--- a/rsvg_internals/src/path_builder.rs
+++ b/rsvg_internals/src/path_builder.rs
@@ -88,7 +88,7 @@ impl EllipticalArc {
         } = self;
 
         // If the end points are identical, omit the arc segment entirely.
-        if x1.approx_eq_cairo(&x2) && y1.approx_eq_cairo(&y2) {
+        if x1.approx_eq_cairo(x2) && y1.approx_eq_cairo(y2) {
             return ArcParameterization::Omit;
         }
 
diff --git a/rsvg_internals/src/pattern.rs b/rsvg_internals/src/pattern.rs
index b387b66f..9d943b1d 100644
--- a/rsvg_internals/src/pattern.rs
+++ b/rsvg_internals/src/pattern.rs
@@ -308,7 +308,7 @@ impl PaintSource for NodePattern {
             draw_ctx.get_view_params()
         };
 
-        if !scwscale.approx_eq_cairo(&1.0) || !schscale.approx_eq_cairo(&1.0) {
+        if !scwscale.approx_eq_cairo(1.0) || !schscale.approx_eq_cairo(1.0) {
             let mut scalematrix = cairo::Matrix::identity();
             scalematrix.scale(scwscale, schscale);
             caffine = cairo::Matrix::multiply(&caffine, &scalematrix);
diff --git a/rsvg_internals/src/rect.rs b/rsvg_internals/src/rect.rs
index fbf37554..f1ab4ed5 100644
--- a/rsvg_internals/src/rect.rs
+++ b/rsvg_internals/src/rect.rs
@@ -22,7 +22,7 @@ impl RectangleExt for cairo::Rectangle {
     }
 
     fn is_empty(&self) -> bool {
-        self.width.approx_eq_cairo(&0.0) || self.height.approx_eq_cairo(&0.0)
+        self.width.approx_eq_cairo(0.0) || self.height.approx_eq_cairo(0.0)
     }
 
     fn intersect(&self, rect: &cairo::Rectangle) -> cairo::Rectangle {
diff --git a/rsvg_internals/src/structure.rs b/rsvg_internals/src/structure.rs
index 868bd772..08254b23 100644
--- a/rsvg_internals/src/structure.rs
+++ b/rsvg_internals/src/structure.rs
@@ -352,7 +352,7 @@ impl NodeTrait for NodeUse {
 
         // width or height set to 0 disables rendering of the element
         // https://www.w3.org/TR/SVG/struct.html#UseElementWidthAttribute
-        if nw.approx_eq_cairo(&0.0) || nh.approx_eq_cairo(&0.0) {
+        if nw.approx_eq_cairo(0.0) || nh.approx_eq_cairo(0.0) {
             return Ok(());
         }
 
diff --git a/rsvg_internals/src/text.rs b/rsvg_internals/src/text.rs
index cb73aff4..99add4f1 100644
--- a/rsvg_internals/src/text.rs
+++ b/rsvg_internals/src/text.rs
@@ -291,7 +291,7 @@ impl PositionedSpan {
             cr.move_to(self.rendered_position.0, self.rendered_position.1);
 
             let rotation = unsafe { pango_sys::pango_gravity_to_rotation(gravity.to_glib()) };
-            if !rotation.approx_eq_cairo(&0.0) {
+            if !rotation.approx_eq_cairo(0.0) {
                 cr.rotate(-rotation);
             }
 
diff --git a/rsvg_internals/src/transform.rs b/rsvg_internals/src/transform.rs
index 32bca3b3..1890e838 100644
--- a/rsvg_internals/src/transform.rs
+++ b/rsvg_internals/src/transform.rs
@@ -255,12 +255,12 @@ mod tests {
     fn assert_matrix_eq(a: &cairo::Matrix, b: &cairo::Matrix) {
         let epsilon = 8.0 * f64::EPSILON; // kind of arbitrary, but allow for some sloppiness
 
-        assert!(a.xx.approx_eq(&b.xx, epsilon, 1));
-        assert!(a.yx.approx_eq(&b.yx, epsilon, 1));
-        assert!(a.xy.approx_eq(&b.xy, epsilon, 1));
-        assert!(a.yy.approx_eq(&b.yy, epsilon, 1));
-        assert!(a.x0.approx_eq(&b.x0, epsilon, 1));
-        assert!(a.y0.approx_eq(&b.y0, epsilon, 1));
+        assert!(a.xx.approx_eq(b.xx, (epsilon, 1)));
+        assert!(a.yx.approx_eq(b.yx, (epsilon, 1)));
+        assert!(a.xy.approx_eq(b.xy, (epsilon, 1)));
+        assert!(a.yy.approx_eq(b.yy, (epsilon, 1)));
+        assert!(a.x0.approx_eq(b.x0, (epsilon, 1)));
+        assert!(a.y0.approx_eq(b.y0, (epsilon, 1)));
     }
 
     #[test]


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]