refactor: please clippy

pull/24376/head
Edd Robinson 2020-02-27 16:45:32 +00:00
parent 01fcff539f
commit c2b49a7804
3 changed files with 41922 additions and 41919 deletions

View File

@ -13,11 +13,14 @@ const LARGER_BATCH_SIZES: [usize; 12] = [
const SMALLER_BATCH_SIZES: [usize; 11] =
[10, 25, 50, 100, 250, 500, 750, 1_000, 5_000, 10_000, 45_000];
type EncodeFn<T> = fn(src: &[T], dst: &mut Vec<u8>) -> Result<(), Box<dyn std::error::Error>>;
type DecodeFn<T> = fn(src: &[u8], dst: &mut Vec<T>) -> Result<(), Box<dyn std::error::Error>>;
fn benchmark_encode_sequential<T: From<i32>>(
c: &mut Criterion,
benchmark_group_name: &str,
batch_sizes: &[usize],
encode: fn(src: &[T], dst: &mut Vec<u8>) -> Result<(), Box<dyn std::error::Error>>,
encode: EncodeFn<T>,
) {
benchmark_encode(
c,
@ -33,7 +36,7 @@ fn benchmark_encode<T>(
benchmark_group_name: &str,
batch_sizes: &[usize],
decoded_value_generation: fn(batch_size: usize) -> Vec<T>,
encode: fn(src: &[T], dst: &mut Vec<u8>) -> Result<(), Box<dyn std::error::Error>>,
encode: EncodeFn<T>,
) {
let mut group = c.benchmark_group(benchmark_group_name);
for &batch_size in batch_sizes {
@ -60,7 +63,7 @@ fn benchmark_decode<T>(
benchmark_group_name: &str,
batch_sizes: &[usize],
input_value_generation: fn(batch_size: usize) -> (usize, Vec<u8>),
decode: fn(src: &[u8], dst: &mut Vec<T>) -> Result<(), Box<dyn std::error::Error>>,
decode: DecodeFn<T>,
) {
let mut group = c.benchmark_group(benchmark_group_name);
for &batch_size in batch_sizes {

File diff suppressed because it is too large Load Diff

View File

@ -260,11 +260,11 @@ mod tests {
#[test]
fn encode_no_values() {
let mut src: Vec<i64> = vec![];
let src: Vec<i64> = vec![];
let mut dst = vec![];
// check for error
encode(&mut src, &mut dst).expect("failed to encode src");
encode(&src, &mut dst).expect("failed to encode src");
// verify encoded no values.
assert_eq!(dst.len(), 0);
@ -272,11 +272,11 @@ mod tests {
#[test]
fn encode_uncompressed() {
let mut src: Vec<i64> = vec![-1000, 0, simple8b::MAX_VALUE as i64, 213123421];
let src: Vec<i64> = vec![-1000, 0, simple8b::MAX_VALUE as i64, 213123421];
let mut dst = vec![];
let exp = src.clone();
encode(&mut src, &mut dst).expect("failed to encode");
encode(&src, &mut dst).expect("failed to encode");
// verify uncompressed encoding used
assert_eq!(&dst[0] >> 4, Encoding::Uncompressed as u8);
@ -332,9 +332,9 @@ mod tests {
for test in tests {
let mut dst = vec![];
let mut src = test.input.clone();
let src = test.input.clone();
let exp = test.input;
encode(&mut src, &mut dst).expect("failed to encode");
encode(&src, &mut dst).expect("failed to encode");
// verify RLE encoding used
assert_eq!(&dst[0] >> 4, Encoding::Rle as u8);
@ -370,9 +370,9 @@ mod tests {
for test in tests {
let mut dst = vec![];
let mut src = test.input.clone();
let src = test.input.clone();
let exp = test.input;
encode(&mut src, &mut dst).expect("failed to encode");
encode(&src, &mut dst).expect("failed to encode");
// verify Simple8b encoding used
assert_eq!(&dst[0] >> 4, Encoding::Simple8b as u8);