[librsvg] Use chunks_exact instead of manual iteration



commit 2a6e8bc2d3b4f967eb652d05618c9b3734656a13
Author: Paolo Borelli <pborelli gnome org>
Date:   Mon Nov 11 11:39:38 2019 +0100

    Use chunks_exact instead of manual iteration

 rsvg_internals/src/property_bag.rs | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)
---
diff --git a/rsvg_internals/src/property_bag.rs b/rsvg_internals/src/property_bag.rs
index f4d3e2b9..daad6836 100644
--- a/rsvg_internals/src/property_bag.rs
+++ b/rsvg_internals/src/property_bag.rs
@@ -39,15 +39,12 @@ impl<'a> PropertyBag<'a> {
         let mut array = Vec::new();
 
         if n_attributes > 0 && !attrs.is_null() {
-            let attrs = slice::from_raw_parts(attrs, n_attributes * 5);
-
-            let mut i = 0;
-            while i < n_attributes * 5 {
-                let localname = attrs[i];
-                let prefix = attrs[i + 1];
-                let uri = attrs[i + 2];
-                let value_start = attrs[i + 3];
-                let value_end = attrs[i + 4];
+            for attr in slice::from_raw_parts(attrs, n_attributes * 5).chunks_exact(5) {
+                let localname = attr[0];
+                let prefix = attr[1];
+                let uri = attr[2];
+                let value_start = attr[3];
+                let value_end = attr[4];
 
                 assert!(!localname.is_null());
 
@@ -89,8 +86,6 @@ impl<'a> PropertyBag<'a> {
 
                     array.push((qual_name, value_str));
                 }
-
-                i += 5;
             }
         }
 


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