From 957e5fdd65ddac8de6f69e2f570551fcd8ed5b82 Mon Sep 17 00:00:00 2001 From: caleb Date: Tue, 15 Aug 2023 15:38:45 +0300 Subject: [PATCH] zune: Fix clippy errors Signed-off-by: caleb --- zune-benches/benches/decode_jpeg.rs | 4 ++-- zune-imageprocs/src/box_blur.rs | 2 +- zune-imageprocs/src/premul_alpha/sse.rs | 2 +- zune-imageprocs/src/traits.rs | 2 +- zune-inflate/src/encoder/hc_matchfinder.rs | 4 ++-- zune-jpeg/src/errors.rs | 2 +- zune-png/src/encoder.rs | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/zune-benches/benches/decode_jpeg.rs b/zune-benches/benches/decode_jpeg.rs index fbcf0e83..d54d0a88 100644 --- a/zune-benches/benches/decode_jpeg.rs +++ b/zune-benches/benches/decode_jpeg.rs @@ -135,7 +135,7 @@ fn decode_hv_samp(c: &mut Criterion) { fn decode_jpeg_grayscale(buf: &[u8]) -> Vec { let options = DecoderOptions::default().jpeg_set_out_colorspace(ColorSpace::Luma); - let mut d = JpegDecoder::new_with_options(options, buf); + let mut d = JpegDecoder::new_with_options(buf, options); d.decode().unwrap() } @@ -253,7 +253,7 @@ fn decode_hv_samp_prog(c: &mut Criterion) { } fn decode_jpeg_opts(buf: &[u8], options: DecoderOptions) -> Vec { - let mut d = JpegDecoder::new_with_options(options, buf); + let mut d = JpegDecoder::new_with_options(buf, options); d.decode().unwrap() } diff --git a/zune-imageprocs/src/box_blur.rs b/zune-imageprocs/src/box_blur.rs index c15b5191..9e1433f1 100644 --- a/zune-imageprocs/src/box_blur.rs +++ b/zune-imageprocs/src/box_blur.rs @@ -165,7 +165,7 @@ pub(crate) fn box_blur_f32_inner( { let half_radius = (radius + 1) / 2; - let mut accumulator: f32 = stride_in[..half_radius].iter().map(|x| f32::from(*x)).sum(); + let mut accumulator: f32 = stride_in[..half_radius].iter().copied().sum(); accumulator += (half_radius as f32) * stride_in[0]; diff --git a/zune-imageprocs/src/premul_alpha/sse.rs b/zune-imageprocs/src/premul_alpha/sse.rs index 9ee46d66..0c57b7ea 100644 --- a/zune-imageprocs/src/premul_alpha/sse.rs +++ b/zune-imageprocs/src/premul_alpha/sse.rs @@ -68,6 +68,6 @@ fn test_inverse_sse_scalar() { assert!(a.is_finite()); assert!(b.is_finite()); - assert!(diff < f32::EPSILON, "{} {}", a, b); + assert!(diff < f32::EPSILON, "{a} {b}"); } } diff --git a/zune-imageprocs/src/traits.rs b/zune-imageprocs/src/traits.rs index ca72a7a2..2e672761 100644 --- a/zune-imageprocs/src/traits.rs +++ b/zune-imageprocs/src/traits.rs @@ -211,7 +211,7 @@ impl NumOps for f32 { } fn to_f64(self) -> f64 { - self as _ + f64::from(self) } fn zclamp(self, min: f32, max: f32) -> f32 { diff --git a/zune-inflate/src/encoder/hc_matchfinder.rs b/zune-inflate/src/encoder/hc_matchfinder.rs index 33efe6a0..217031e9 100644 --- a/zune-inflate/src/encoder/hc_matchfinder.rs +++ b/zune-inflate/src/encoder/hc_matchfinder.rs @@ -190,7 +190,7 @@ impl HcMatchFinder { // compute the next hash codes let n_hash4 = v_hash(next_window, HASH_FOUR_LOG_SIZE, self.min_length); - self.next_hash[1] = n_hash4 as usize; + self.next_hash[1] = n_hash4; let mut match_found = false; if cur_offset != 0 { @@ -271,7 +271,7 @@ impl HcMatchFinder { depth -= 1; } } - return match_found; + match_found } #[inline(always)] diff --git a/zune-jpeg/src/errors.rs b/zune-jpeg/src/errors.rs index 8cd0c563..d1fc006f 100644 --- a/zune-jpeg/src/errors.rs +++ b/zune-jpeg/src/errors.rs @@ -86,7 +86,7 @@ impl Debug for DecodeErrors { Self::ExhaustedData => write!(f, "Exhausted data in the image"), Self::LargeDimensions(ref dimensions) => write!( f, - "Too large dimensions {dimensions},library supports up to {MAX_DIMENSIONS}" + "Too large dimensions {dimensions},library supports up to {}", crate::decoder::MAX_DIMENSIONS ), Self::TooSmallOutput(expected, found) => write!(f, "Too small output, expected buffer with at least {expected} bytes but got one with {found} bytes") } diff --git a/zune-png/src/encoder.rs b/zune-png/src/encoder.rs index 52a3af76..45a69425 100644 --- a/zune-png/src/encoder.rs +++ b/zune-png/src/encoder.rs @@ -90,7 +90,7 @@ impl<'a> PngEncoder<'a> { // divide each into 8192 bytes let mut extra_bytes = (raw_len + 8191) / 8192; // for each extra byte, add header, length and crc - extra_bytes = extra_bytes * (4 + 4 + 4); + extra_bytes *= 4 + 4 + 4; out_dims += extra_bytes; }