Skip to content

Commit

Permalink
fix unused functions warnings by either deleting or gating behind cfgs
Browse files Browse the repository at this point in the history
  • Loading branch information
KillingSpark committed Dec 14, 2024
1 parent e95ab2a commit 0f6611b
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 37 deletions.
5 changes: 0 additions & 5 deletions src/decoding/bit_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,4 @@ impl<'s> BitReader<'s> {

Ok(value)
}

pub fn reset(&mut self, new_source: &'s [u8]) {
self.idx = 0;
self.source = new_source;
}
}
7 changes: 0 additions & 7 deletions src/decoding/bit_reader_reverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,4 @@ impl<'s> BitReaderReversed<'s> {

value_masked
}

pub fn reset(&mut self, new_source: &'s [u8]) {
self.idx = new_source.len() as isize * 8;
self.source = new_source;
self.bit_container = 0;
self.bits_in_container = 0;
}
}
4 changes: 0 additions & 4 deletions src/decoding/decodebuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ impl DecodeBuffer {
self.buffer.len()
}

pub fn is_empty(&self) -> bool {
self.buffer.is_empty()
}

pub fn push(&mut self, data: &[u8]) {
self.buffer.extend(data);
self.total_output_counter += data.len() as u64;
Expand Down
1 change: 1 addition & 0 deletions src/decoding/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ impl FrameDescriptor {

/// This bit is reserved for some future feature, a compliant decoder **must ensure**
/// that this value is set to zero.
#[expect(dead_code)]
pub fn reserved_flag(&self) -> bool {
((self.0 >> 3) & 0x1) == 1
}
Expand Down
5 changes: 0 additions & 5 deletions src/decoding/ringbuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ impl RingBuffer {
self.tail = 0;
}

/// Whether the buffer is empty
pub fn is_empty(&self) -> bool {
self.head == self.tail
}

/// Ensure that there's space for `amount` elements in the buffer.
pub fn reserve(&mut self, amount: usize) {
let free = self.free();
Expand Down
2 changes: 2 additions & 0 deletions src/fse/fse_encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ impl<V: AsMut<Vec<u8>>> FSEEncoder<'_, V> {
FSEEncoder { table, writer }
}

#[cfg(any(test, feature = "fuzz_exports"))]
pub fn into_table(self) -> FSETable {
self.table
}
Expand All @@ -21,6 +22,7 @@ impl<V: AsMut<Vec<u8>>> FSEEncoder<'_, V> {
/// * Encoded data
/// * Last state index
/// * Padding bits to fill up last byte
#[cfg(any(test, feature = "fuzz_exports"))]
pub fn encode(&mut self, data: &[u8]) {
self.write_table();

Expand Down
6 changes: 4 additions & 2 deletions src/fse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
mod fse_decoder;

pub use fse_decoder::*;
use fse_encoder::FSEEncoder;

use crate::{decoding::bit_reader_reverse::BitReaderReversed, encoding::bit_writer::BitWriter};
pub mod fse_encoder;

#[test]
Expand All @@ -30,6 +28,7 @@ fn tables_equal() {
check_tables(&dec_table, &enc_table);
}

#[cfg(any(test, feature = "fuzz_exports"))]
fn check_tables(dec_table: &fse_decoder::FSETable, enc_table: &fse_encoder::FSETable) {
for (idx, dec_state) in dec_table.decode.iter().enumerate() {
let enc_states = &enc_table.states[dec_state.symbol as usize];
Expand Down Expand Up @@ -79,6 +78,9 @@ fn roundtrip() {
/// Asserts that the decoded data equals the input
#[cfg(any(test, feature = "fuzz_exports"))]
pub fn round_trip(data: &[u8]) {
use crate::{decoding::bit_reader_reverse::BitReaderReversed, encoding::bit_writer::BitWriter};
use fse_encoder::FSEEncoder;

if data.len() < 2 {
return;
}
Expand Down
10 changes: 0 additions & 10 deletions src/huff0/huff0_decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,6 @@ impl<'t> HuffmanDecoder<'t> {
HuffmanDecoder { table, state: 0 }
}

/// Re-initialize the decoder, using the new table if one is provided.
/// This might used for treeless blocks, because they re-use the table from old
/// data.
pub fn reset(mut self, new_table: Option<&'t HuffmanTable>) {
self.state = 0;
if let Some(next_table) = new_table {
self.table = next_table;
}
}

/// Decode the symbol the internal state (cursor) is pointed at and return the
/// decoded literal.
pub fn decode_symbol(&mut self) -> u8 {
Expand Down
8 changes: 4 additions & 4 deletions src/huff0/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
/// used symbols get longer codes. Codes are prefix free, meaning no two codes
/// will start with the same sequence of bits.
mod huff0_decoder;
use alloc::vec::Vec;

pub use huff0_decoder::*;

use crate::{decoding::bit_reader_reverse::BitReaderReversed, encoding::bit_writer::BitWriter};
pub mod huff0_encoder;

/// Only needed for testing.
Expand All @@ -17,6 +13,9 @@ pub mod huff0_encoder;
/// Asserts that the decoded data equals the input
#[cfg(any(test, feature = "fuzz_exports"))]
pub fn round_trip(data: &[u8]) {
use crate::{decoding::bit_reader_reverse::BitReaderReversed, encoding::bit_writer::BitWriter};
use alloc::vec::Vec;

if data.len() < 2 {
return;
}
Expand Down Expand Up @@ -58,6 +57,7 @@ pub fn round_trip(data: &[u8]) {

#[test]
fn roundtrip() {
use alloc::vec::Vec;
round_trip(&[1, 1, 1, 1, 2, 3]);
round_trip(&[1, 1, 1, 1, 2, 3, 5, 45, 12, 90]);

Expand Down

0 comments on commit 0f6611b

Please sign in to comment.