[librsvg: 7/12] Clear useless_let_if_seq warnings.



commit 8070eaa9c36cf2aa080cc999a9e3a2508b14bc19
Author: Jordan Petridis <jordanpetridis protonmail com>
Date:   Sun Dec 17 10:51:22 2017 +0200

    Clear useless_let_if_seq warnings.
    
    For more see:
    https://rust-lang-nursery.github.io/rust-clippy/v0.0.176/index.html#useless_let_if_seq

 rust/src/bbox.rs        | 38 +++++----------------
 rust/src/gradient.rs    | 10 +++---
 rust/src/path_parser.rs | 90 ++++++++++++++++++++-----------------------------
 3 files changed, 49 insertions(+), 89 deletions(-)
---
diff --git a/rust/src/bbox.rs b/rust/src/bbox.rs
index 5a5dc13..b395a6b 100644
--- a/rust/src/bbox.rs
+++ b/rust/src/bbox.rs
@@ -41,22 +41,11 @@ pub extern fn rsvg_bbox_insert (raw_dst: *mut RsvgBbox, raw_src: *const RsvgBbox
         return;
     }
 
-    let mut xmin: f64;
-    let mut ymin: f64;
-    let mut xmax: f64;
-    let mut ymax: f64;
-
-    if !dst.is_virgin () {
-        xmin = dst.rect.x;
-        ymin = dst.rect.y;
-        xmax = dst.rect.x + dst.rect.width;
-        ymax = dst.rect.y + dst.rect.height;
+    let (mut xmin, mut ymin, mut xmax, mut ymax) = if !dst.is_virgin () {
+        (dst.rect.y, dst.rect.y, (dst.rect.x + dst.rect.width), (dst.rect.y + dst.rect.height))
     } else {
-        xmin = 0.0;
-        ymin = 0.0;
-        xmax = 0.0;
-        ymax = 0.0;
-    }
+        (0.0, 0.0, 0.0, 0.0)
+    };
 
     let mut affine = dst.affine;
 
@@ -108,22 +97,11 @@ pub extern fn rsvg_bbox_clip (raw_dst: *mut RsvgBbox, raw_src: *const RsvgBbox)
         return;
     }
 
-    let mut xmin: f64;
-    let mut ymin: f64;
-    let mut xmax: f64;
-    let mut ymax: f64;
-
-    if !dst.is_virgin () {
-        xmin = dst.rect.x + dst.rect.width;
-        ymin = dst.rect.y + dst.rect.height;
-        xmax = dst.rect.x;
-        ymax = dst.rect.y;
+    let (mut xmin, mut ymin, mut xmax, mut ymax) = if !dst.is_virgin () {
+        ((dst.rect.x + dst.rect.width), (dst.rect.y + dst.rect.height), dst.rect.x, dst.rect.y)
     } else {
-        xmin = 0.0;
-        ymin = 0.0;
-        xmax = 0.0;
-        ymax = 0.0;
-    }
+        (0.0, 0.0, 0.0, 0.0)
+    };
 
     let mut affine = dst.affine;
 
diff --git a/rust/src/gradient.rs b/rust/src/gradient.rs
index d46663c..4a94582 100644
--- a/rust/src/gradient.rs
+++ b/rust/src/gradient.rs
@@ -144,11 +144,11 @@ impl GradientCommon {
         }
 
         if let Some (ref mut stops) = self.stops {
-            let mut last_offset: f64 = 0.0;
-
-            if !stops.is_empty() {
-                last_offset = stops[stops.len () - 1].offset;
-            }
+            let last_offset: f64 = if !stops.is_empty() {
+                stops[stops.len () - 1].offset
+            } else {
+                0.0
+            };
 
             if last_offset > offset {
                 offset = last_offset;
diff --git a/rust/src/path_parser.rs b/rust/src/path_parser.rs
index 1a71d2a..24b975d 100644
--- a/rust/src/path_parser.rs
+++ b/rust/src/path_parser.rs
@@ -446,14 +446,12 @@ impl<'b> PathParser<'b> {
 
     fn moveto (&mut self, is_initial_moveto: bool) -> bool {
         if self.lookahead_is ('M') || self.lookahead_is ('m') {
-            let absolute: bool;
-
-            if self.match_char ('M') {
-                absolute = true;
+            let absolute = if self.match_char ('M') {
+                true
             } else {
                 assert! (self.match_char ('m'));
-                absolute = false;
-            }
+                false
+            };
 
             return self.optional_whitespace () &&
                 self.moveto_argument_sequence (absolute, is_initial_moveto);
@@ -522,14 +520,12 @@ impl<'b> PathParser<'b> {
 
     fn line_to (&mut self) -> bool {
         if self.lookahead_is ('L') || self.lookahead_is ('l') {
-            let absolute: bool;
-
-            if self.match_char ('L') {
-                absolute = true;
+            let absolute = if self.match_char ('L') {
+                true
             } else {
                 assert! (self.match_char ('l'));
-                absolute = false;
-            }
+                false
+            };
 
             self.optional_whitespace ();
 
@@ -574,14 +570,12 @@ impl<'b> PathParser<'b> {
 
     fn horizontal_line_to (&mut self) -> bool {
         if self.lookahead_is ('H') || self.lookahead_is ('h') {
-            let absolute: bool;
-
-            if self.match_char ('H') {
-                absolute = true;
+            let absolute = if self.match_char ('H') {
+                true
             } else {
                 assert! (self.match_char ('h'));
-                absolute = false;
-            }
+                false
+            };
 
             self.optional_whitespace ();
 
@@ -626,14 +620,12 @@ impl<'b> PathParser<'b> {
 
     fn vertical_line_to (&mut self) -> bool {
         if self.lookahead_is ('V') || self.lookahead_is ('v') {
-            let absolute: bool;
-
-            if self.match_char ('V') {
-                absolute = true;
+            let absolute = if self.match_char ('V') {
+                true
             } else {
                 assert! (self.match_char ('v'));
-                absolute = false;
-            }
+                false
+            };
 
             self.optional_whitespace ();
 
@@ -731,14 +723,12 @@ impl<'b> PathParser<'b> {
 
     fn curve_to (&mut self) -> bool {
         if self.lookahead_is ('C') || self.lookahead_is ('c') {
-            let absolute: bool;
-
-            if self.match_char ('C') {
-                absolute = true;
+            let absolute = if self.match_char ('C') {
+                true
             } else {
                 assert! (self.match_char ('c'));
-                absolute = false;
-            }
+                false
+            };
 
             self.optional_whitespace ();
 
@@ -754,14 +744,12 @@ impl<'b> PathParser<'b> {
 
     fn smooth_curve_to (&mut self) -> bool {
         if self.lookahead_is ('S') || self.lookahead_is ('s') {
-            let absolute: bool;
-
-            if self.match_char ('S') {
-                absolute = true;
+            let absolute = if self.match_char ('S') {
+                true
             } else {
                 assert! (self.match_char ('s'));
-                absolute = false;
-            }
+                false
+            };
 
             self.optional_whitespace ();
 
@@ -813,14 +801,12 @@ impl<'b> PathParser<'b> {
 
     fn quadratic_bezier_curve_to (&mut self) -> bool {
         if self.lookahead_is ('Q') || self.lookahead_is ('q') {
-            let absolute: bool;
-
-            if self.match_char ('Q') {
-                absolute = true;
+            let absolute = if self.match_char ('Q') {
+                true
             } else {
                 assert! (self.match_char ('q'));
-                absolute = false;
-            }
+                false
+            };
 
             self.optional_whitespace ();
 
@@ -867,14 +853,12 @@ impl<'b> PathParser<'b> {
 
     fn smooth_quadratic_bezier_curve_to (&mut self) -> bool {
         if self.lookahead_is ('T') || self.lookahead_is ('t') {
-            let absolute: bool;
-
-            if self.match_char ('T') {
-                absolute = true;
+            let absolute = if self.match_char ('T') {
+                true
             } else {
                 assert! (self.match_char ('t'));
-                absolute = false;
-            }
+                false
+            };
 
             self.optional_whitespace ();
 
@@ -958,14 +942,12 @@ impl<'b> PathParser<'b> {
 
     fn elliptical_arc (&mut self) -> bool {
         if self.lookahead_is ('A') || self.lookahead_is ('a') {
-            let absolute: bool;
-
-            if self.match_char ('A') {
-                absolute = true;
+            let absolute = if self.match_char ('A') {
+                true
             } else {
                 assert! (self.match_char ('a'));
-                absolute = false;
-            }
+                false
+            };
 
             self.optional_whitespace ();
 


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