Skip to content

Commit 5ad7153

Browse files
authored
Merge pull request #196 from nyurik/use-crate
Switch to `use crate::` for local decl
2 parents 27ce5f5 + 6622aeb commit 5ad7153

22 files changed

+64
-67
lines changed

src/enc/backward_references/hash_to_binary_tree.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
#![allow(dead_code)]
22

33
use alloc::{Allocator, SliceWrapper, SliceWrapperMut};
4+
use core;
45
use core::cmp::min;
56

6-
use enc::static_dict::{BrotliDictionary, FindMatchLengthWithLimit, BROTLI_UNALIGNED_LOAD32};
7-
use enc::util::floatX;
8-
use {alloc, core};
9-
107
use super::{
118
kHashMul32, AnyHasher, BrotliEncoderParams, CloneWithAlloc, H9Opts, HasherSearchResult,
129
HowPrepared, Struct1,
1310
};
11+
use crate::enc::static_dict::{
12+
BrotliDictionary, FindMatchLengthWithLimit, BROTLI_UNALIGNED_LOAD32,
13+
};
14+
use crate::enc::util::floatX;
1415

1516
pub const kInfinity: floatX = 1.7e38 as floatX;
1617

src/enc/backward_references/hq.rs

+12-13
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,6 @@ use alloc::{Allocator, SliceWrapper, SliceWrapperMut};
44
use core;
55
use core::cmp::{max, min};
66

7-
use enc::command::{
8-
BrotliDistanceParams, CombineLengthCodes, Command, GetCopyLengthCode, GetInsertLengthCode,
9-
PrefixEncodeCopyDistance,
10-
};
11-
use enc::constants::{kCopyExtra, kInsExtra};
12-
use enc::encode;
13-
use enc::literal_cost::BrotliEstimateBitCostsForLiterals;
14-
use enc::static_dict::{
15-
BrotliDictionary, BrotliFindAllStaticDictionaryMatches, FindMatchLengthWithLimit,
16-
BROTLI_UNALIGNED_LOAD32,
17-
};
18-
use enc::util::{floatX, FastLog2, FastLog2f64};
19-
207
use super::hash_to_binary_tree::{
218
kInfinity, Allocable, BackwardMatch, BackwardMatchMut, H10Params, StoreAndFindMatchesH10,
229
Union1, ZopfliNode, H10,
@@ -25,6 +12,18 @@ use super::{
2512
kDistanceCacheIndex, kDistanceCacheOffset, kHashMul32, kInvalidMatch, AnyHasher,
2613
BrotliEncoderParams,
2714
};
15+
use crate::enc::command::{
16+
BrotliDistanceParams, CombineLengthCodes, Command, GetCopyLengthCode, GetInsertLengthCode,
17+
PrefixEncodeCopyDistance,
18+
};
19+
use crate::enc::constants::{kCopyExtra, kInsExtra};
20+
use crate::enc::encode;
21+
use crate::enc::literal_cost::BrotliEstimateBitCostsForLiterals;
22+
use crate::enc::static_dict::{
23+
BrotliDictionary, BrotliFindAllStaticDictionaryMatches, FindMatchLengthWithLimit,
24+
BROTLI_UNALIGNED_LOAD32,
25+
};
26+
use crate::enc::util::{floatX, FastLog2, FastLog2f64};
2827

2928
const BROTLI_WINDOW_GAP: usize = 16;
3029
const BROTLI_MAX_STATIC_DICTIONARY_MATCH_LEN: usize = 37;

src/enc/backward_references/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
#![cfg(test)]
33

44
use alloc_stdlib::StandardAlloc;
5-
use enc::{Allocator, SliceWrapper};
65

76
use super::{
87
AdvHasher, AnyHasher, BrotliHasherParams, CloneWithAlloc, H5Sub, H9Opts, HQ7Sub, Struct1,
98
};
9+
use crate::enc::{Allocator, SliceWrapper};
1010

1111
static RANDOM_THEN_UNICODE: &[u8] = include_bytes!("../../../testdata/random_then_unicode"); //&[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55];
1212

src/enc/brotli_bit_stream.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ use core::cmp::{max, min};
66
#[cfg(feature = "std")]
77
use std::io::Write;
88

9-
use enc::backward_references::BrotliEncoderParams;
10-
use VERSION;
11-
129
use super::super::alloc::{Allocator, SliceWrapper, SliceWrapperMut};
1310
use super::super::dictionary::{
1411
kBrotliDictionary, kBrotliDictionaryOffsetsByLength, kBrotliDictionarySizeBitsByLength,
@@ -38,6 +35,8 @@ use super::interface::StaticCommand;
3835
use super::static_dict::kNumDistanceCacheEntries;
3936
use super::util::floatX;
4037
use super::{find_stride, interface, prior_eval, stride_eval};
38+
use crate::enc::backward_references::BrotliEncoderParams;
39+
use crate::VERSION;
4140

4241
pub struct PrefixCodeRange {
4342
pub offset: u32,
@@ -2956,7 +2955,7 @@ pub fn BrotliWriteMetadataMetaBlock(
29562955

29572956
#[cfg(test)]
29582957
mod test {
2959-
use enc::brotli_bit_stream::{encode_base_128, MAX_SIZE_ENCODING};
2958+
use crate::enc::brotli_bit_stream::{encode_base_128, MAX_SIZE_ENCODING};
29602959

29612960
#[test]
29622961
fn test_encode_base_128() {

src/enc/context_map_entropy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ impl<'a, Alloc: alloc::Allocator<u16> + alloc::Allocator<u32> + alloc::Allocator
539539
fn literal_context_map(&self) -> &[u8] {
540540
self.context_map.literal_context_map.slice()
541541
}
542-
fn prediction_mode(&self) -> ::interface::LiteralPredictionModeNibble {
542+
fn prediction_mode(&self) -> crate::interface::LiteralPredictionModeNibble {
543543
self.context_map.literal_prediction_mode()
544544
}
545545
fn update_cost(

src/enc/encode.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ use alloc::Allocator;
44
use core;
55
use core::cmp::{max, min};
66

7-
use enc::input_pair::InputReferenceMut;
8-
97
use super::super::alloc;
108
use super::super::alloc::{SliceWrapper, SliceWrapperMut};
119
use super::backward_references::{
@@ -41,6 +39,7 @@ pub use super::parameters::BrotliEncoderParameter;
4139
use super::static_dict::{kNumDistanceCacheEntries, BrotliGetDictionary};
4240
use super::utf8_util::BrotliIsMostlyUTF8;
4341
use super::util::Log2FloorNonZero;
42+
use crate::enc::input_pair::InputReferenceMut;
4443

4544
//fn BrotliCreateHqZopfliBackwardReferences(m: &mut [MemoryManager],
4645
// dictionary: &[BrotliDictionary],

src/enc/ir_interpret.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub trait IRInterpreter {
1111
fn block_type(&self) -> u8;
1212
fn literal_data_at_offset(&self, index: usize) -> u8;
1313
fn literal_context_map(&self) -> &[u8];
14-
fn prediction_mode(&self) -> ::interface::LiteralPredictionModeNibble;
14+
fn prediction_mode(&self) -> crate::interface::LiteralPredictionModeNibble;
1515
fn update_cost(
1616
&mut self,
1717
stride_prior: [u8; 8],

src/enc/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ pub use alloc_stdlib::StandardAlloc;
5353
use brotli_decompressor::{CustomRead, CustomWrite};
5454
#[cfg(feature = "std")]
5555
pub use brotli_decompressor::{IntoIoReader, IoReaderWrapper, IoWriterWrapper};
56-
use enc::encode::BrotliEncoderStateStruct;
5756
pub use interface::{InputPair, InputReference, InputReferenceMut};
5857

5958
pub use self::backward_references::{
@@ -76,6 +75,7 @@ pub use self::util::floatX;
7675
pub use self::vectorization::{v256, v256i, Mem256f};
7776
#[cfg(feature = "std")]
7877
pub use self::worker_pool::{compress_worker_pool, new_work_pool, WorkerPool};
78+
use crate::enc::encode::BrotliEncoderStateStruct;
7979

8080
#[cfg(feature = "simd")]
8181
pub type s16 = core::simd::i16x16;

src/enc/multithreading.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ use std;
88
use std::sync::RwLock;
99
use std::thread::JoinHandle;
1010

11-
use enc::backward_references::UnionHasher;
12-
use enc::threading::{
11+
use crate::enc::backward_references::UnionHasher;
12+
use crate::enc::threading::{
1313
AnyBoxConstructor, BatchSpawnable, BatchSpawnableLite, BrotliEncoderThreadError, CompressMulti,
1414
CompressionThreadResult, InternalOwned, InternalSendAlloc, Joinable, Owned, OwnedRetriever,
1515
PoisonedThreadError, SendAlloc,
1616
};
17-
use enc::{BrotliAlloc, BrotliEncoderParams};
17+
use crate::enc::{BrotliAlloc, BrotliEncoderParams};
1818

1919
pub struct MultiThreadedJoinable<T: Send + 'static, U: Send + 'static>(
2020
JoinHandle<T>,

src/enc/prior_eval.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ impl<'a, Alloc: alloc::Allocator<s16> + alloc::Allocator<u32> + alloc::Allocator
856856
self.context_map.literal_context_map.slice()
857857
}
858858
#[inline]
859-
fn prediction_mode(&self) -> ::interface::LiteralPredictionModeNibble {
859+
fn prediction_mode(&self) -> crate::interface::LiteralPredictionModeNibble {
860860
self.context_map.literal_prediction_mode()
861861
}
862862
#[inline]

src/enc/singlethreading.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ use core::mem;
44
#[cfg(feature = "std")]
55
use std;
66

7-
use enc::threading::{
7+
use super::backward_references::UnionHasher;
8+
use crate::enc::threading::{
89
BatchSpawnable, BatchSpawnableLite, BrotliEncoderThreadError, CompressMulti,
910
CompressionThreadResult, InternalOwned, InternalSendAlloc, Joinable, Owned, OwnedRetriever,
1011
PoisonedThreadError, SendAlloc,
1112
};
12-
use enc::{BrotliAlloc, BrotliEncoderParams};
13-
14-
use super::backward_references::UnionHasher;
13+
use crate::enc::{BrotliAlloc, BrotliEncoderParams};
1514

1615
pub struct SingleThreadedJoinable<T: Send + 'static, U: Send + 'static> {
1716
result: Result<T, U>,

src/enc/stride_eval.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ impl<'a, Alloc: alloc::Allocator<u16> + alloc::Allocator<u32> + alloc::Allocator
293293
fn literal_context_map(&self) -> &[u8] {
294294
self.context_map.literal_context_map.slice()
295295
}
296-
fn prediction_mode(&self) -> ::interface::LiteralPredictionModeNibble {
296+
fn prediction_mode(&self) -> crate::interface::LiteralPredictionModeNibble {
297297
self.context_map.literal_prediction_mode()
298298
}
299299
fn update_cost(

src/enc/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use core::cmp::min;
1919
use core::ops;
2020

2121
use brotli_decompressor::HuffmanCode;
22-
use enc::encode::BrotliEncoderStateStruct;
2322

2423
use super::super::alloc::{
2524
bzero, AllocatedStackMemory, Allocator, SliceWrapper, SliceWrapperMut, StackAllocator,
@@ -33,6 +32,7 @@ use super::entropy_encode::HuffmanTree;
3332
use super::histogram::{ContextType, HistogramCommand, HistogramDistance, HistogramLiteral};
3433
use super::pdf::PDF;
3534
use super::{interface, s16, v8, StaticCommand, ZopfliNode};
35+
use crate::enc::encode::BrotliEncoderStateStruct;
3636

3737
declare_stack_allocator_struct!(MemPool, 128, stack);
3838
declare_stack_allocator_struct!(CallocatedFreelist4096, 128, calloc);

src/enc/threading.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ use core::{any, mem};
55
#[cfg(feature = "std")]
66
use std;
77

8-
use concat::{BroCatli, BroCatliResult};
9-
use enc::encode::BrotliEncoderStateStruct;
10-
118
use super::backward_references::{AnyHasher, BrotliEncoderParams, CloneWithAlloc, UnionHasher};
129
use super::encode::{
1310
BrotliEncoderDestroyInstance, BrotliEncoderMaxCompressedSize, BrotliEncoderOperation,
1411
HasherSetup, SanitizeParams,
1512
};
1613
use super::BrotliAlloc;
14+
use crate::concat::{BroCatli, BroCatliResult};
15+
use crate::enc::encode::BrotliEncoderStateStruct;
1716

1817
pub type PoisonedThreadError = ();
1918

src/enc/vectorization.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#![allow(unknown_lints)]
22
#![allow(unused_macros)]
33

4-
use enc::util::FastLog2;
5-
use enc::{s8, v8};
4+
use crate::enc::util::FastLog2;
5+
use crate::enc::{s8, v8};
66
pub type Mem256f = v8;
77
pub type Mem256i = s8;
88
pub type v256 = v8;

src/enc/worker_pool.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ use std;
77
use std::sync::RwLock;
88
use std::sync::{Arc, Condvar, Mutex};
99

10-
use enc::backward_references::UnionHasher;
11-
use enc::fixed_queue::{FixedQueue, MAX_THREADS};
12-
use enc::threading::{
10+
use crate::enc::backward_references::UnionHasher;
11+
use crate::enc::fixed_queue::{FixedQueue, MAX_THREADS};
12+
use crate::enc::threading::{
1313
BatchSpawnableLite, BrotliEncoderThreadError, CompressMulti, CompressionThreadResult,
1414
InternalOwned, InternalSendAlloc, Joinable, Owned, SendAlloc,
1515
};
16-
use enc::{BrotliAlloc, BrotliEncoderParams};
16+
use crate::enc::{BrotliAlloc, BrotliEncoderParams};
1717

1818
struct JobReply<T: Send + 'static> {
1919
result: T,

src/ffi/alloc_util.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use alloc::{Allocator, SliceWrapper, SliceWrapperMut};
22

33
use brotli_decompressor::ffi::alloc_util::SubclassableAllocator;
4-
use enc::BrotliAlloc;
4+
5+
use crate::enc::BrotliAlloc;
56

67
pub struct BrotliSubclassableAllocator(SubclassableAllocator);
78

src/ffi/broccoli.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ use core;
22

33
pub use brotli_decompressor::ffi::interface::c_void;
44
use brotli_decompressor::ffi::{slice_from_raw_parts_or_nil, slice_from_raw_parts_or_nil_mut};
5-
use concat::BroCatli;
6-
pub use concat::BroCatliResult;
5+
6+
use crate::concat::BroCatli;
7+
pub use crate::concat::BroCatliResult;
78
pub type BroccoliResult = BroCatliResult;
89
// a tool to concatenate brotli files together
910

src/ffi/compressor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ use brotli_decompressor::ffi::interface::{
1313
use brotli_decompressor::ffi::{
1414
alloc_util, slice_from_raw_parts_or_nil, slice_from_raw_parts_or_nil_mut,
1515
};
16-
use enc::encode::BrotliEncoderStateStruct;
1716

1817
use super::alloc_util::BrotliSubclassableAllocator;
18+
use crate::enc::encode::BrotliEncoderStateStruct;
1919

2020
#[repr(C)]
2121
pub enum BrotliEncoderOperation {

src/ffi/multicompress/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ use brotli_decompressor::ffi::interface::{
1212
brotli_alloc_func, brotli_free_func, c_void, CAllocator,
1313
};
1414
use brotli_decompressor::ffi::{slice_from_raw_parts_or_nil, slice_from_raw_parts_or_nil_mut};
15-
use enc::backward_references::{BrotliEncoderParams, UnionHasher};
16-
use enc::encode::{
17-
set_parameter, BrotliEncoderOperation, BrotliEncoderParameter, BrotliEncoderStateStruct,
18-
};
19-
use enc::threading::{Owned, SendAlloc};
2015
use {brotli_decompressor, core, enc};
2116

2217
use super::alloc_util::BrotliSubclassableAllocator;
2318
use super::compressor;
19+
use crate::enc::backward_references::{BrotliEncoderParams, UnionHasher};
20+
use crate::enc::encode::{
21+
set_parameter, BrotliEncoderOperation, BrotliEncoderParameter, BrotliEncoderStateStruct,
22+
};
23+
use crate::enc::threading::{Owned, SendAlloc};
2424

2525
pub const MAX_THREADS: usize = 16;
2626

src/ffi/multicompress/test.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
use core;
55

6-
use enc::encode::BrotliEncoderParameter;
7-
86
use super::*;
7+
use crate::enc::encode::BrotliEncoderParameter;
98

109
#[test]
1110
fn test_compress_workpool() {

src/lib.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,19 @@ pub use brotli_decompressor::{
5050
dictionary, reader, transform, writer, BrotliDecompressCustomIo,
5151
BrotliDecompressCustomIoCustomDict, BrotliDecompressStream, BrotliResult, BrotliState,
5252
};
53-
pub use enc::input_pair::{InputPair, InputReference, InputReferenceMut};
54-
pub use enc::interface::SliceOffset;
53+
54+
pub use self::enc::combined_alloc::CombiningAllocator;
55+
pub use crate::enc::input_pair::{InputPair, InputReference, InputReferenceMut};
56+
pub use crate::enc::interface::SliceOffset;
5557
#[cfg(feature = "std")]
56-
pub use enc::reader::CompressorReader;
57-
pub use enc::reader::CompressorReaderCustomIo;
58+
pub use crate::enc::reader::CompressorReader;
59+
pub use crate::enc::reader::CompressorReaderCustomIo;
5860
#[cfg(feature = "std")]
59-
pub use enc::writer::CompressorWriter;
60-
pub use enc::writer::CompressorWriterCustomIo;
61-
pub use enc::{interface, BrotliCompressCustomIo, BrotliCompressCustomIoCustomDict};
61+
pub use crate::enc::writer::CompressorWriter;
62+
pub use crate::enc::writer::CompressorWriterCustomIo;
63+
pub use crate::enc::{interface, BrotliCompressCustomIo, BrotliCompressCustomIoCustomDict};
6264
#[cfg(feature = "std")]
63-
pub use enc::{BrotliCompress, BrotliCompressCustomAlloc};
64-
65-
pub use self::enc::combined_alloc::CombiningAllocator;
65+
pub use crate::enc::{BrotliCompress, BrotliCompressCustomAlloc};
6666

6767
pub const VERSION: u8 = 1;
6868

0 commit comments

Comments
 (0)