From 87def30596ce27078228abea6c660af8c91c8fce Mon Sep 17 00:00:00 2001 From: Alexander Weiss Date: Wed, 4 Jan 2023 22:22:23 +0100 Subject: [PATCH] fix compiler errors --- benches/benchmarks.rs | 4 ++-- src/rolling_hash.rs | 12 ++++++------ src/separator.rs | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/benches/benchmarks.rs b/benches/benchmarks.rs index a4c8981..13948c8 100644 --- a/benches/benchmarks.rs +++ b/benches/benchmarks.rs @@ -2,7 +2,7 @@ extern crate cdc; extern crate criterion; use cdc::{Rabin64, RollingHash64}; -use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use criterion::{criterion_group, criterion_main, Criterion}; pub fn slide_benchmarks(c: &mut Criterion) { for i in [1_000, 10_000, 100_000] { @@ -11,7 +11,7 @@ pub fn slide_benchmarks(c: &mut Criterion) { b.iter(|| { let mut rabin = Rabin64::new(5); for _ in 0..i { - rabin.slide(&data) + rabin.slide(data) } }) }); diff --git a/src/rolling_hash.rs b/src/rolling_hash.rs index ca5fa08..2f4cc12 100644 --- a/src/rolling_hash.rs +++ b/src/rolling_hash.rs @@ -8,7 +8,7 @@ pub trait RollingHash64 { fn reset_and_prefill_window(&mut self, iter: &mut I) -> usize where I: Iterator; - fn slide(&mut self, byte: &u8); + fn slide(&mut self, byte: u8); fn get_hash(&self) -> &Polynom64; } @@ -108,7 +108,7 @@ impl RollingHash64 for Rabin64 { for _ in 0..self.window_size - 1 { match iter.next() { Some(b) => { - self.slide(&b); + self.slide(b); nb_bytes_read += 1; } None => break, @@ -154,16 +154,16 @@ impl RollingHash64 for Rabin64 { } #[inline] - fn slide(&mut self, byte: &u8) { + fn slide(&mut self, byte: u8) { // Take the old value out of the window and the hash. let out_value = self.window_data[self.window_index]; self.hash ^= self.out_table[out_value as usize]; // Put the new value in the window and in the hash. - self.window_data[self.window_index] = *byte; + self.window_data[self.window_index] = byte; let mod_index = (self.hash >> self.polynom_shift) & 255; self.hash <<= 8; - self.hash |= *byte as Polynom64; + self.hash |= byte as Polynom64; self.hash ^= self.mod_table[mod_index as usize]; // Move the windowIndex to the next position. @@ -216,7 +216,7 @@ mod tests { rabin1.reset(); rabin1.hash_block(block, &MOD_POLYNOM); - rabin2.slide(&data[i]); + rabin2.slide(data[i]); //println!("{:02} {:02} {:016x} {:016x} {:?}", i, block.len(), rabin1.hash, rabin2.hash, block); assert_eq!(rabin1.hash, rabin2.hash); diff --git a/src/separator.rs b/src/separator.rs index e6f9a97..83367e1 100644 --- a/src/separator.rs +++ b/src/separator.rs @@ -62,7 +62,7 @@ where #[inline] fn next(&mut self) -> Option { while let Some(byte) = self.iter.next() { - self.rabin.slide(&byte); + self.rabin.slide(byte); self.index += 1; if (self.predicate)(self.rabin.hash) { let separator = Separator {