a bit more simplification without an apparent performance gain
authoralfadur
Tue, 06 Nov 2018 23:45:54 +0300
changeset 14149 8e2e98760003
parent 14148 d3c9025abd13
child 14150 6205a5230d23
a bit more simplification without an apparent performance gain
rust/land2d/src/lib.rs
--- a/rust/land2d/src/lib.rs	Tue Nov 06 23:29:12 2018 +0300
+++ b/rust/land2d/src/lib.rs	Tue Nov 06 23:45:54 2018 +0300
@@ -151,14 +151,12 @@
 
         while let Some((mut xl, mut xr, y, dir)) = stack.pop() {
             let row = &mut self.pixels[y][..];
-            while xl > 0 && row.get(xl)
-                .map_or(false, |v| *v != border_value && *v != fill_value)
+            while xl > 0 && row[xl] != border_value && row[xl] != fill_value
             {
                 xl -= 1;
             }
 
-            while xr < width - 1 && row.get(xr)
-                .map_or(false, |v| *v != border_value && *v != fill_value)
+            while xr < width - 1 && row[xr] != border_value && row[xr] != fill_value
             {
                 xr += 1;
             }
@@ -171,7 +169,7 @@
 
                 let x = xl;
 
-                while xl <= xr && (row[xl] != border_value && row[xl] != fill_value)
+                while xl <= xr && row[xl] != border_value && row[xl] != fill_value
                 {
                     row[xl] = fill_value;
                     xl += 1;