Skip to content

Commit

Permalink
Fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
as-com committed Dec 29, 2023
1 parent 0b9407e commit e144688
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
Cargo.lock
/.idea
.DS_Store
14 changes: 7 additions & 7 deletions benches/varint_bench/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ fn decode_batched_varint_simd_unsafe<T: VarIntTarget, const C: usize>(
// SAFETY: the input slice should have at least 16 bytes of allocated padding at the end
let (num, len) = unsafe { decode_unsafe::<T>(slice.as_ptr()) };
out[i] = num;
slice = &slice[(len as usize)..];
slice = &slice[len..];
}
}

Expand Down Expand Up @@ -153,7 +153,7 @@ fn decode_batched_varint_simd_safe<T: VarIntTarget, const C: usize>(input: &mut
for i in 0..C {
let (num, len) = decode::<T>(slice).unwrap();
out[i] = num;
slice = &slice[(len as usize)..];
slice = &slice[len..];
}
}

Expand Down Expand Up @@ -366,7 +366,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
});

group.bench_function("varint-simd", |b| {
b.iter_batched(|| rng.gen::<u8>(), |num| encode(num), BatchSize::SmallInput)
b.iter_batched(|| rng.gen::<u8>(), encode, BatchSize::SmallInput)
});
group.finish();

Expand Down Expand Up @@ -470,7 +470,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
group.bench_function("varint-simd", |b| {
b.iter_batched(
|| rng.gen::<u16>(),
|num| encode(num),
encode,
BatchSize::SmallInput,
)
});
Expand Down Expand Up @@ -567,7 +567,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
group.bench_function("varint-simd", |b| {
b.iter_batched(
|| rng.gen::<u32>(),
|num| encode(num),
encode,
BatchSize::SmallInput,
)
});
Expand Down Expand Up @@ -656,7 +656,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|| rng.gen::<u64>(),
|num| {
target.clear();
prost_varint::encode_varint(num as u64, &mut target)
prost_varint::encode_varint(num, &mut target)
},
BatchSize::SmallInput,
)
Expand All @@ -665,7 +665,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
group.bench_function("varint-simd", |b| {
b.iter_batched(
|| rng.gen::<u64>(),
|num| encode(num),
encode,
BatchSize::SmallInput,
)
});
Expand Down
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -222,7 +222,7 @@ mod tests {
}
}

#[cfg(any(target_feature = "avx2"))]
#[cfg(target_feature = "avx2")]
fn check_decode_wide_2x<T: VarIntTarget, U: VarIntTarget>(a: &[T], b: &[U]) {
for i in a {
for j in b {
Expand Down Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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::<u8, u8>(&NUMS_U8[..], &NUMS_U8[..]);
check_decode_wide_2x::<u8, u16>(&NUMS_U8[..], &NUMS_U16[..]);
Expand All @@ -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::<u16, u8>(&NUMS_U16[..], &NUMS_U8[..]);
check_decode_wide_2x::<u16, u16>(&NUMS_U16[..], &NUMS_U16[..]);
Expand All @@ -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::<u32, u8>(&NUMS_U32[..], &NUMS_U8[..]);
check_decode_wide_2x::<u32, u16>(&NUMS_U32[..], &NUMS_U16[..]);
Expand All @@ -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::<u64, u8>(&NUMS_U64[..], &NUMS_U8[..]);
check_decode_wide_2x::<u64, u16>(&NUMS_U64[..], &NUMS_U16[..]);
Expand Down

0 comments on commit e144688

Please sign in to comment.