Skip to content

Commit 8950401

Browse files
authored
Merge pull request #204 from nyurik/rm-dead-code
Remove dead code
2 parents 910c1bd + 1017ce8 commit 8950401

18 files changed

+10
-122
lines changed

src/enc/backward_references/hash_to_binary_tree.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(dead_code)]
2-
31
use alloc::{Allocator, SliceWrapper, SliceWrapperMut};
42
use core;
53
use core::cmp::min;

src/enc/backward_references/hq.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(dead_code)]
2-
31
use alloc::{Allocator, SliceWrapper, SliceWrapperMut};
42
use core;
53
use core::cmp::{max, min};
@@ -9,8 +7,7 @@ use super::hash_to_binary_tree::{
97
Union1, ZopfliNode, H10,
108
};
119
use super::{
12-
kDistanceCacheIndex, kDistanceCacheOffset, kHashMul32, kInvalidMatch, AnyHasher,
13-
BrotliEncoderParams,
10+
kDistanceCacheIndex, kDistanceCacheOffset, kInvalidMatch, AnyHasher, BrotliEncoderParams,
1411
};
1512
use crate::enc::combined_alloc::{alloc_if, alloc_or_default};
1613
use crate::enc::command::{
@@ -22,7 +19,6 @@ use crate::enc::encode;
2219
use crate::enc::literal_cost::BrotliEstimateBitCostsForLiterals;
2320
use crate::enc::static_dict::{
2421
BrotliDictionary, BrotliFindAllStaticDictionaryMatches, FindMatchLengthWithLimit,
25-
BROTLI_UNALIGNED_LOAD32,
2622
};
2723
use crate::enc::util::{floatX, FastLog2, FastLog2f64};
2824

@@ -256,12 +252,6 @@ impl<AllocF: Allocator<floatX>> ZopfliCostModel<AllocF> {
256252
}
257253
}
258254

259-
#[inline(always)]
260-
fn HashBytesH10(data: &[u8]) -> u32 {
261-
let h: u32 = BROTLI_UNALIGNED_LOAD32(data).wrapping_mul(kHashMul32);
262-
h >> (32i32 - 17i32)
263-
}
264-
265255
pub fn StitchToPreviousBlockH10<
266256
AllocU32: Allocator<u32>,
267257
Buckets: Allocable<u32, AllocU32> + SliceWrapperMut<u32> + SliceWrapper<u32>,

src/enc/backward_references/mod.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(dead_code)]
2-
31
mod benchmark;
42
pub mod hash_to_binary_tree;
53
pub mod hq;
@@ -18,8 +16,6 @@ use super::static_dict::{
1816
use super::util::{floatX, Log2FloorNonZero};
1917
use crate::enc::combined_alloc::allocate;
2018

21-
static kBrotliMinWindowBits: i32 = 10;
22-
static kBrotliMaxWindowBits: i32 = 24;
2319
pub static kInvalidMatch: u32 = 0x0fff_ffff;
2420
static kCutoffTransformsCount: u32 = 10;
2521
static kCutoffTransforms: u64 = 0x071b_520a_da2d_3200;
@@ -1281,6 +1277,8 @@ impl<
12811277
}
12821278
ix_start
12831279
}
1280+
1281+
#[cfg(feature = "benchmark")]
12841282
fn BulkStoreRangeOptMemFetchLazyDupeUpdate(
12851283
&mut self,
12861284
data: &[u8],
@@ -1363,6 +1361,8 @@ impl<
13631361
}
13641362
ix_start
13651363
}
1364+
1365+
#[cfg(feature = "benchmark")]
13661366
fn BulkStoreRangeOptRandomDupeUpdate(
13671367
&mut self,
13681368
data: &[u8],
@@ -1821,19 +1821,9 @@ pub struct H42 {
18211821
pub head: [u16; 32768],
18221822
pub tiny_hash: [u8; 65536],
18231823
pub banks: [BankH42; 512],
1824-
free_slot_idx: [u16; 512],
18251824
pub max_hops: usize,
18261825
}
18271826

1828-
fn unopt_ctzll(mut val: usize) -> u8 {
1829-
let mut cnt: u8 = 0u8;
1830-
while val & 1 == 0usize {
1831-
val >>= 1i32;
1832-
cnt = (cnt as i32 + 1) as u8;
1833-
}
1834-
cnt
1835-
}
1836-
18371827
fn BackwardReferenceScoreUsingLastDistance(copy_length: usize, h9_opts: H9Opts) -> u64 {
18381828
((h9_opts.literal_byte_score as u64) >> 2)
18391829
.wrapping_mul(copy_length as u64)

src/enc/bit_cost.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(dead_code)]
2-
31
use core::cmp::{max, min};
42

53
use super::super::alloc::SliceWrapper;
@@ -8,18 +6,6 @@ use super::util::{FastLog2, FastLog2u16};
86
use super::vectorization::Mem256i;
97
use crate::enc::floatX;
108

11-
static kCopyBase: [u32; 24] = [
12-
2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 18, 22, 30, 38, 54, 70, 102, 134, 198, 326, 582, 1094, 2118,
13-
];
14-
15-
static kCopyExtra: [u32; 24] = [
16-
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10, 24,
17-
];
18-
19-
static kBrotliMinWindowBits: i32 = 10i32;
20-
21-
static kBrotliMaxWindowBits: i32 = 24i32;
22-
239
pub fn ShannonEntropy(mut population: &[u32], size: usize, total: &mut usize) -> floatX {
2410
let mut sum: usize = 0usize;
2511
let mut retval: floatX = 0.0;

src/enc/block_split.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(dead_code)]
2-
31
use super::super::alloc;
42
use super::super::alloc::{Allocator, SliceWrapper};
53
use crate::enc::combined_alloc::alloc_default;

src/enc/block_splitter.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(dead_code)]
2-
31
use core;
42
use core::cmp::{max, min};
53
#[cfg(feature = "simd")]

src/enc/brotli_bit_stream.rs

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![allow(unknown_lints)]
2-
#![allow(dead_code)]
32
#![allow(unused_macros)]
43

54
use core::cmp::{max, min};
@@ -49,48 +48,10 @@ fn window_size_from_lgwin(lgwin: i32) -> usize {
4948
(1 << lgwin) - 16usize
5049
}
5150

52-
fn context_type_str(context_type: ContextType) -> &'static str {
53-
match context_type {
54-
ContextType::CONTEXT_LSB6 => "lsb6",
55-
ContextType::CONTEXT_MSB6 => "msb6",
56-
ContextType::CONTEXT_UTF8 => "utf8",
57-
ContextType::CONTEXT_SIGNED => "sign",
58-
}
59-
}
60-
61-
fn prediction_mode_str(
62-
prediction_mode_nibble: interface::LiteralPredictionModeNibble,
63-
) -> &'static str {
64-
match prediction_mode_nibble.prediction_mode() {
65-
interface::LITERAL_PREDICTION_MODE_SIGN => "sign",
66-
interface::LITERAL_PREDICTION_MODE_LSB6 => "lsb6",
67-
interface::LITERAL_PREDICTION_MODE_MSB6 => "msb6",
68-
interface::LITERAL_PREDICTION_MODE_UTF8 => "utf8",
69-
_ => "unknown",
70-
}
71-
}
72-
73-
fn is_long_enough_to_be_random(len: usize, high_entropy_detection_quality: u8) -> bool {
74-
match high_entropy_detection_quality {
75-
0 => false,
76-
1 => false,
77-
2 => len >= 128,
78-
3 => len >= 96,
79-
4 => len >= 64,
80-
5 => len >= 48,
81-
6 => len >= 32,
82-
7 => len >= 24,
83-
8 => len >= 16,
84-
9 => len >= 8,
85-
10 => len >= 4,
86-
11 => len >= 1,
87-
_ => len >= 8,
88-
}
89-
}
90-
const COMMAND_BUFFER_SIZE: usize = 4096;
91-
9251
struct CommandQueue<'a, Alloc: BrotliAlloc + 'a> {
9352
mb: InputPair<'a>,
53+
// TODO: delete unused fields
54+
#[allow(dead_code)]
9455
mb_byte_offset: usize,
9556
mc: &'a mut Alloc,
9657
queue: <Alloc as Allocator<StaticCommand>>::AllocatedMemory,
@@ -100,9 +61,12 @@ struct CommandQueue<'a, Alloc: BrotliAlloc + 'a> {
10061
best_strides_per_block_type: <Alloc as Allocator<u8>>::AllocatedMemory,
10162
entropy_pyramid: find_stride::EntropyPyramid<Alloc>,
10263
context_map_entropy: ContextMapEntropy<'a, Alloc>,
64+
#[allow(dead_code)]
10365
stride_detection_quality: u8,
66+
#[allow(dead_code)]
10467
high_entropy_detection_quality: u8,
10568
block_type_literal: u8,
69+
#[allow(dead_code)]
10670
best_stride_index: usize,
10771
overfull: bool,
10872
}
@@ -149,9 +113,6 @@ impl<'a, Alloc: BrotliAlloc> CommandQueue<'a, Alloc> {
149113
self.overfull = true;
150114
}
151115
}
152-
fn size(&self) -> usize {
153-
self.loc
154-
}
155116
fn clear(&mut self) {
156117
self.loc = 0;
157118
self.block_type_literal = 0;
@@ -2435,8 +2396,6 @@ fn StoreDataWithHuffmanCodes(
24352396
}
24362397
}
24372398

2438-
fn nop<'a>(_data: &[interface::Command<InputReference>]) {}
2439-
24402399
#[deprecated(note = "use store_meta_block_trivial instead")]
24412400
pub fn BrotliStoreMetaBlockTrivial<Alloc: BrotliAlloc, Cb>(
24422401
alloc: &mut Alloc,

src/enc/cluster.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(dead_code)]
2-
31
use alloc::{Allocator, SliceWrapper, SliceWrapperMut};
42
use core::cmp::min;
53

src/enc/compress_fragment.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(dead_code)]
2-
31
use core::cmp::min;
42

53
//caution: lots of the functions look structurally the same as two_pass,

src/enc/compress_fragment_two_pass.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(dead_code)]
2-
31
use core;
42
use core::cmp::min;
53

0 commit comments

Comments
 (0)