Skip to content

Commit

Permalink
fix nightly, clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
PSeitz committed Mar 19, 2024
1 parent 4e87de7 commit 3d439e7
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 15 deletions.
5 changes: 2 additions & 3 deletions src/block/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ use crate::sink::Sink;
use crate::sink::SliceSink;
#[allow(unused_imports)]
use alloc::vec;
use alloc::vec::Vec;

#[cfg(feature = "safe-encode")]
use core::convert::TryInto;
#[allow(unused_imports)]
use alloc::vec::Vec;

use super::hashtable::HashTable4K;
use super::hashtable::HashTable4KU16;
Expand Down
5 changes: 3 additions & 2 deletions src/block/decompress_safe.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
//! The block decompression algorithm.
use core::convert::TryInto;

use crate::block::DecompressError;
use crate::block::MINMATCH;
use crate::sink::Sink;
use crate::sink::SliceSink;

#[allow(unused_imports)]
use alloc::vec;
#[allow(unused_imports)]
use alloc::vec::Vec;

/// Read an integer.
Expand Down
3 changes: 2 additions & 1 deletion src/block/hashtable.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[allow(unused_imports)]
use alloc::boxed::Box;
use core::convert::TryInto;

/// The Hashtable trait used by the compression to store hashed bytes to their position.
/// `val` can be maximum the size of the input in bytes.
Expand Down Expand Up @@ -36,6 +36,7 @@ fn hash5(sequence: usize) -> u32 {
pub trait HashTable {
fn get_at(&self, pos: usize) -> usize;
fn put_at(&mut self, pos: usize, val: usize);
#[allow(dead_code)]
fn clear(&mut self);
#[inline]
#[cfg(target_pointer_width = "64")]
Expand Down
1 change: 0 additions & 1 deletion src/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ pub(crate) mod decompress;
pub use compress::*;
pub use decompress::*;

use core::convert::TryInto;
use core::fmt;

pub(crate) const WINDOW_SIZE: usize = 64 * 1024;
Expand Down
5 changes: 2 additions & 3 deletions src/frame/decompress.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::{
convert::TryInto,
fmt,
hash::Hasher,
io::{self, BufRead, ErrorKind},
Expand Down Expand Up @@ -371,7 +370,7 @@ impl<R: io::Read> io::Read for FrameDecoder<R> {
let mut written = 0;
loop {
match self.fill_buf() {
Ok(b) if b.is_empty() => return Ok(written),
Ok([]) => return Ok(written),

Check warning on line 373 in src/frame/decompress.rs

View check run for this annotation

Codecov / codecov/patch

src/frame/decompress.rs#L373

Added line #L373 was not covered by tests
Ok(b) => {
let s = std::str::from_utf8(b).map_err(|_| {
io::Error::new(
Expand All @@ -394,7 +393,7 @@ impl<R: io::Read> io::Read for FrameDecoder<R> {
let mut written = 0;
loop {
match self.fill_buf() {
Ok(b) if b.is_empty() => return Ok(written),
Ok([]) => return Ok(written),
Ok(b) => {
buf.extend_from_slice(b);
let len = b.len();
Expand Down
1 change: 0 additions & 1 deletion src/frame/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use twox_hash::XxHash32;

use super::Error;
use std::{
convert::TryInto,
fmt::Debug,
hash::Hasher,
io,
Expand Down
9 changes: 5 additions & 4 deletions src/sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ pub fn vec_sink_for_compression(
pos: usize,
required_capacity: usize,
) -> SliceSink {
return {
{
vec.resize(offset + required_capacity, 0);
SliceSink::new(&mut vec[offset..], pos)
};
}
}

/// Returns a Sink implementation appropriate for outputing up to `required_capacity`
Expand All @@ -35,10 +35,10 @@ pub fn vec_sink_for_decompression(
pos: usize,
required_capacity: usize,
) -> SliceSink {
return {
{
vec.resize(offset + required_capacity, 0);
SliceSink::new(&mut vec[offset..], pos)
};
}
}

pub trait Sink {
Expand All @@ -47,6 +47,7 @@ pub trait Sink {
unsafe fn pos_mut_ptr(&mut self) -> *mut u8;

/// read byte at position
#[allow(dead_code)]
fn byte_at(&mut self, pos: usize) -> u8;

/// Pushes a byte to the end of the Sink.
Expand Down
5 changes: 5 additions & 0 deletions src/test_bins/compress_block.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn main() {
use lz4_flex::compress_prepend_size;
let input = "Hello people, what's up?".to_string();
let _compressed = compress_prepend_size(input.as_bytes());
}

0 comments on commit 3d439e7

Please sign in to comment.