From f4b643d54bf64a3d579332aa192c6b68561b5af5 Mon Sep 17 00:00:00 2001 From: Josh Holmer Date: Fri, 16 Dec 2016 21:24:47 -0500 Subject: [PATCH] Fix clippy lints, now that clippy is working again. Hooray! --- Cargo.lock | 18 +++++++++--------- src/png.rs | 33 ++++++++++++--------------------- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3ddf81a3..944bd788 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5,12 +5,12 @@ dependencies = [ "bit-vec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.19.2 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "crc 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "image 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "libz-sys 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "miniz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -68,15 +68,15 @@ dependencies = [ [[package]] name = "clippy" -version = "0.0.103" +version = "0.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "clippy_lints 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy_lints 0.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "clippy_lints" -version = "0.0.103" +version = "0.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -184,7 +184,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libz-sys" -version = "1.0.7" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -450,8 +450,8 @@ dependencies = [ "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855" "checksum clap 2.19.2 (registry+https://github.com/rust-lang/crates.io-index)" = "305ad043f009db535a110200541d4567b63e172b1fe030313fbb92565da7ed24" -"checksum clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "5b4fabf979ddf6419a313c1c0ada4a5b95cfd2049c56e8418d622d27b4b6ff32" -"checksum clippy_lints 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "ce96ec05bfe018a0d5d43da115e54850ea2217981ff0f2e462780ab9d594651a" +"checksum clippy 0.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "ae3fb361e922a08b698e746d4f199ff2d1e8d4b5f1984eaf8881e720cf5b8e34" +"checksum clippy_lints 0.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "70812027c1a8de9277d125557dce08262bc27508f2eb99592ad2d39a24a0b1c7" "checksum crc 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2a3f9159e74024e2cdb6f574e9117cdc2e91523a890930a022823d17abedc90a" "checksum deque 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1614659040e711785ed8ea24219140654da1729f3ec8a47a9719d041112fe7bf" "checksum either 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3d2b503c86dad62aaf414ecf2b8c527439abedb3f8d812537f0b12bfd6f32a91" @@ -465,7 +465,7 @@ dependencies = [ "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6abe0ee2e758cd6bc8a2cd56726359007748fbf4128da998b65d0b70f881e19b" "checksum libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "a51822fc847e7a8101514d1d44e354ba2ffa7d4c194dcab48870740e327cac70" -"checksum libz-sys 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "283c2d162f78c5090522e13fc809820c33181570ae40de1bea84f3864c8759f9" +"checksum libz-sys 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)" = "905c72a0c260bcd89ddca5afa1c46bebd29b52878a3d58c86865ea42402f88e6" "checksum matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efd7622e3022e1a6eaa602c4cea8912254e5582c9c692e9167714182244801b1" "checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" "checksum miniz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d1f4d337a01c32e1f2122510fed46393d53ca35a7f429cb0450abaedfa3ed54" diff --git a/src/png.rs b/src/png.rs index 851802e9..a7d69e8d 100644 --- a/src/png.rs +++ b/src/png.rs @@ -653,9 +653,7 @@ impl PngData { // Go down one step at a time // Maybe not the most efficient, but it's safe if self.ihdr_data.color_type == ColorType::RGBA { - if reduce_rgba_to_grayscale_alpha(self) { - changed = true; - } else if reduce_rgba_to_rgb(self) { + if reduce_rgba_to_grayscale_alpha(self) || reduce_rgba_to_rgb(self) { changed = true; } else if reduce_rgba_to_palette(self) { changed = true; @@ -663,28 +661,21 @@ impl PngData { } } - if self.ihdr_data.color_type == ColorType::GrayscaleAlpha { - if reduce_grayscale_alpha_to_grayscale(self) { - changed = true; - should_reduce_bit_depth = true; - } + if self.ihdr_data.color_type == ColorType::GrayscaleAlpha && + reduce_grayscale_alpha_to_grayscale(self) { + changed = true; + should_reduce_bit_depth = true; } - if self.ihdr_data.color_type == ColorType::RGB { - if reduce_rgb_to_grayscale(self) { - changed = true; - should_reduce_bit_depth = true; - } else if reduce_rgb_to_palette(self) { - changed = true; - should_reduce_bit_depth = true; - } + if self.ihdr_data.color_type == ColorType::RGB && + (reduce_rgb_to_grayscale(self) || reduce_rgb_to_palette(self)) { + changed = true; + should_reduce_bit_depth = true; } - if self.ihdr_data.color_type == ColorType::Grayscale { - if reduce_grayscale_to_palette(self) { - changed = true; - should_reduce_bit_depth = true; - } + if self.ihdr_data.color_type == ColorType::Grayscale && reduce_grayscale_to_palette(self) { + changed = true; + should_reduce_bit_depth = true; } if should_reduce_bit_depth {