From e144688cfbd150029ced610df47572ca9c756c09 Mon Sep 17 00:00:00 2001 From: Andrew Sun Date: Fri, 29 Dec 2023 11:46:47 -0500 Subject: [PATCH] Fix clippy --- .gitignore | 1 + benches/varint_bench/main.rs | 14 +++++++------- src/lib.rs | 14 +++++++------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 2de3917..aea98f6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target Cargo.lock /.idea +.DS_Store diff --git a/benches/varint_bench/main.rs b/benches/varint_bench/main.rs index 74c6ceb..4387ebf 100644 --- a/benches/varint_bench/main.rs +++ b/benches/varint_bench/main.rs @@ -76,7 +76,7 @@ fn decode_batched_varint_simd_unsafe( // SAFETY: the input slice should have at least 16 bytes of allocated padding at the end let (num, len) = unsafe { decode_unsafe::(slice.as_ptr()) }; out[i] = num; - slice = &slice[(len as usize)..]; + slice = &slice[len..]; } } @@ -153,7 +153,7 @@ fn decode_batched_varint_simd_safe(input: &mut for i in 0..C { let (num, len) = decode::(slice).unwrap(); out[i] = num; - slice = &slice[(len as usize)..]; + slice = &slice[len..]; } } @@ -366,7 +366,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { }); group.bench_function("varint-simd", |b| { - b.iter_batched(|| rng.gen::(), |num| encode(num), BatchSize::SmallInput) + b.iter_batched(|| rng.gen::(), encode, BatchSize::SmallInput) }); group.finish(); @@ -470,7 +470,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { group.bench_function("varint-simd", |b| { b.iter_batched( || rng.gen::(), - |num| encode(num), + encode, BatchSize::SmallInput, ) }); @@ -567,7 +567,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { group.bench_function("varint-simd", |b| { b.iter_batched( || rng.gen::(), - |num| encode(num), + encode, BatchSize::SmallInput, ) }); @@ -656,7 +656,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { || rng.gen::(), |num| { target.clear(); - prost_varint::encode_varint(num as u64, &mut target) + prost_varint::encode_varint(num, &mut target) }, BatchSize::SmallInput, ) @@ -665,7 +665,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { group.bench_function("varint-simd", |b| { b.iter_batched( || rng.gen::(), - |num| encode(num), + encode, BatchSize::SmallInput, ) }); diff --git a/src/lib.rs b/src/lib.rs index 1862c45..1d21f8d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -54,7 +54,7 @@ impl std::error::Error for VarIntDecodeError {} #[cfg(test)] mod tests { - #[cfg(any(target_feature = "avx2"))] + #[cfg(target_feature = "avx2")] use crate::decode_two_wide_unsafe; use crate::{ decode, decode_eight_u8_unsafe, decode_four_unsafe, decode_two_unsafe, encode, @@ -222,7 +222,7 @@ mod tests { } } - #[cfg(any(target_feature = "avx2"))] + #[cfg(target_feature = "avx2")] fn check_decode_wide_2x(a: &[T], b: &[U]) { for i in a { for j in b { @@ -271,7 +271,7 @@ mod tests { assert_eq!(decoded.5, second_len); assert_eq!(decoded.6, third_len); assert_eq!(decoded.7, fourth_len); - assert_eq!(decoded.8, false); + assert!(!decoded.8); } } } @@ -345,7 +345,7 @@ mod tests { } #[test] - #[cfg(any(target_feature = "avx2"))] + #[cfg(target_feature = "avx2")] fn test_decode_2x_wide_u8_x() { check_decode_wide_2x::(&NUMS_U8[..], &NUMS_U8[..]); check_decode_wide_2x::(&NUMS_U8[..], &NUMS_U16[..]); @@ -362,7 +362,7 @@ mod tests { } #[test] - #[cfg(any(target_feature = "avx2"))] + #[cfg(target_feature = "avx2")] fn test_decode_2x_wide_u16_x() { check_decode_wide_2x::(&NUMS_U16[..], &NUMS_U8[..]); check_decode_wide_2x::(&NUMS_U16[..], &NUMS_U16[..]); @@ -379,7 +379,7 @@ mod tests { } #[test] - #[cfg(any(target_feature = "avx2"))] + #[cfg(target_feature = "avx2")] fn test_decode_2x_wide_u32_x() { check_decode_wide_2x::(&NUMS_U32[..], &NUMS_U8[..]); check_decode_wide_2x::(&NUMS_U32[..], &NUMS_U16[..]); @@ -396,7 +396,7 @@ mod tests { } #[test] - #[cfg(any(target_feature = "avx2"))] + #[cfg(target_feature = "avx2")] fn test_decode_2x_wide_u64_x() { check_decode_wide_2x::(&NUMS_U64[..], &NUMS_U8[..]); check_decode_wide_2x::(&NUMS_U64[..], &NUMS_U16[..]);