Skip to content

Commit da54ef1

Browse files
committed
Simplify derefs (*foo).bar() into foo.bar()
\(\*([a-z][a-z0-9_]*)\)\. -> $1. And fixed (reverted) a few that didn't compile
1 parent 7cbd844 commit da54ef1

15 files changed

+306
-306
lines changed

corrosion/backward_references_hq.rs

Lines changed: 90 additions & 90 deletions
Large diffs are not rendered by default.

corrosion/backward_references_hq_safe.rs

Lines changed: 90 additions & 90 deletions
Large diffs are not rendered by default.

src/enc/backward_references/hash_to_binary_tree.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,8 @@ impl<'a> BackwardMatchMut<'a> {
380380

381381
#[inline(always)]
382382
pub fn InitBackwardMatch(xself: &mut BackwardMatchMut, dist: usize, len: usize) {
383-
(*xself).set_distance(dist as u32);
384-
(*xself).set_length_and_code((len << 5) as u32);
383+
xself.set_distance(dist as u32);
384+
xself.set_length_and_code((len << 5) as u32);
385385
}
386386

387387
macro_rules! LeftChildIndexH10 {
@@ -402,7 +402,7 @@ fn LeftChildIndexH10<AllocU32: Allocator<u32>,
402402
Params:H10Params>(
403403
mut xself : &mut H10<AllocU32, Buckets, Params>, pos : usize
404404
) -> usize {
405-
(2usize).wrapping_mul(pos & (*xself).window_mask_)
405+
(2usize).wrapping_mul(pos & xself.window_mask_)
406406
}
407407
408408
fn RightChildIndexH10<AllocU32: Allocator<u32>,
@@ -411,7 +411,7 @@ fn RightChildIndexH10<AllocU32: Allocator<u32>,
411411
mut xself : &mut H10<AllocU32, Buckets, Params>, pos : usize
412412
) -> usize {
413413
(2usize).wrapping_mul(
414-
pos & (*xself).window_mask_
414+
pos & xself.window_mask_
415415
).wrapping_add(
416416
1
417417
)

src/enc/backward_references/hq.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,12 @@ pub fn BrotliZopfliCreateCommands(
160160
dist_cache[0] = distance as i32;
161161
}
162162
}
163-
*num_literals = (*num_literals).wrapping_add(insert_length);
163+
*num_literals = num_literals.wrapping_add(insert_length);
164164
pos = pos.wrapping_add(copy_length);
165165
}
166166
i = i.wrapping_add(1);
167167
}
168-
*last_insert_len = (*last_insert_len).wrapping_add(num_bytes.wrapping_sub(pos));
168+
*last_insert_len = last_insert_len.wrapping_add(num_bytes.wrapping_sub(pos));
169169
}
170170

171171
#[inline(always)]
@@ -307,7 +307,7 @@ fn InitDictionaryBackwardMatch(
307307
len: usize,
308308
len_code: usize,
309309
) {
310-
(*xself).set_distance(dist as u32);
310+
xself.set_distance(dist as u32);
311311
(*xself)
312312
.set_length_and_code((len << 5 | if len == len_code { 0usize } else { len_code }) as u32);
313313
}
@@ -490,7 +490,7 @@ where
490490

491491
#[inline(always)]
492492
fn BackwardMatchLength(xself: &BackwardMatch) -> usize {
493-
((*xself).length_and_code() >> 5) as usize
493+
(xself.length_and_code() >> 5) as usize
494494
}
495495

496496
#[inline(always)]
@@ -720,7 +720,7 @@ fn UpdateZopfliNode(
720720

721721
#[inline(always)]
722722
fn BackwardMatchLengthCode(xself: &BackwardMatch) -> usize {
723-
let code: usize = ((*xself).length_and_code() & 31u32) as usize;
723+
let code: usize = (xself.length_and_code() & 31u32) as usize;
724724
if code != 0 {
725725
code
726726
} else {
@@ -1144,7 +1144,7 @@ pub fn BrotliCreateZopfliBackwardReferences<
11441144
return;
11451145
}
11461146
BrotliInitZopfliNodes(nodes.slice_mut(), num_bytes.wrapping_add(1));
1147-
*num_commands = (*num_commands).wrapping_add(BrotliZopfliComputeShortestPath(
1147+
*num_commands = num_commands.wrapping_add(BrotliZopfliComputeShortestPath(
11481148
alloc,
11491149
dictionary,
11501150
num_bytes,
@@ -1503,7 +1503,7 @@ pub fn BrotliCreateHqZopfliBackwardReferences<
15031503
}
15041504
let num_found_matches: usize = FindAllMatchesH10(
15051505
hasher,
1506-
dictionary, //&(*params).dictionary ,
1506+
dictionary, //&params.dictionary ,
15071507
ringbuffer,
15081508
ringbuffer_mask,
15091509
pos,
@@ -1598,7 +1598,7 @@ pub fn BrotliCreateHqZopfliBackwardReferences<
15981598
ringbuffer,
15991599
ringbuffer_mask,
16001600
commands,
1601-
(*num_commands).wrapping_sub(orig_num_commands),
1601+
num_commands.wrapping_sub(orig_num_commands),
16021602
orig_last_insert_len,
16031603
);
16041604
}
@@ -1613,7 +1613,7 @@ pub fn BrotliCreateHqZopfliBackwardReferences<
16131613
{
16141614
*i = *j;
16151615
}
1616-
*num_commands = (*num_commands).wrapping_add(ZopfliIterate(
1616+
*num_commands = num_commands.wrapping_add(ZopfliIterate(
16171617
num_bytes,
16181618
position,
16191619
ringbuffer,

src/enc/backward_references/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,7 +1407,7 @@ impl<
14071407
* self.specialization.get_k_hash_mul())
14081408
& self.specialization.get_hash_mask();
14091409
let key = mixed_word >> shift;
1410-
let minor_ix: usize = chunk_id & self.specialization.block_mask() as usize; // *num_ref as usize & (*self).specialization.block_mask() as usize; //GIGANTIC HAX: overwrite firsst option
1410+
let minor_ix: usize = chunk_id & self.specialization.block_mask() as usize; // *num_ref as usize & self.specialization.block_mask() as usize; //GIGANTIC HAX: overwrite firsst option
14111411
let offset: usize =
14121412
minor_ix + (key << self.specialization.block_bits()) as usize;
14131413
buckets[offset] = (ix_offset + i) as u32;
@@ -2501,7 +2501,7 @@ fn CreateBackwardReferences<AH: AnyHasher>(
25012501
distance_code,
25022502
);
25032503
}
2504-
*num_literals = (*num_literals).wrapping_add(insert_length);
2504+
*num_literals = num_literals.wrapping_add(insert_length);
25052505
insert_length = 0usize;
25062506
hasher.StoreRange(
25072507
ringbuffer,
@@ -2537,7 +2537,7 @@ fn CreateBackwardReferences<AH: AnyHasher>(
25372537
}
25382538
insert_length = insert_length.wrapping_add(pos_end.wrapping_sub(position));
25392539
*last_insert_len = insert_length;
2540-
*num_commands = (*num_commands).wrapping_add(new_commands_count);
2540+
*num_commands = num_commands.wrapping_add(new_commands_count);
25412541
}
25422542
pub fn BrotliCreateBackwardReferences<
25432543
Alloc: alloc::Allocator<u16>

src/enc/bit_cost.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -250,19 +250,19 @@ pub fn BrotliPopulationCost<HistogramType: SliceWrapper<u32> + CostAccessors>(
250250
static kTwoSymbolHistogramCost: super::util::floatX = 20i32 as super::util::floatX;
251251
static kThreeSymbolHistogramCost: super::util::floatX = 28i32 as super::util::floatX;
252252
static kFourSymbolHistogramCost: super::util::floatX = 37i32 as super::util::floatX;
253-
let data_size: usize = (*histogram).slice().len();
253+
let data_size: usize = histogram.slice().len();
254254
let mut count: i32 = 0i32;
255255
let mut s: [usize; 5] = [0; 5];
256256

257257
let mut bits: super::util::floatX = 0.0 as super::util::floatX;
258258
let mut i: usize;
259-
if (*histogram).total_count() == 0usize {
259+
if histogram.total_count() == 0usize {
260260
return kOneSymbolHistogramCost;
261261
}
262262
i = 0usize;
263263
'break1: while i < data_size {
264264
{
265-
if (*histogram).slice()[i] > 0u32 {
265+
if histogram.slice()[i] > 0u32 {
266266
s[count as usize] = i;
267267
count += 1;
268268
if count > 4i32 {
@@ -278,12 +278,12 @@ pub fn BrotliPopulationCost<HistogramType: SliceWrapper<u32> + CostAccessors>(
278278
return kOneSymbolHistogramCost;
279279
}
280280
if count == 2i32 {
281-
return kTwoSymbolHistogramCost + (*histogram).total_count() as super::util::floatX;
281+
return kTwoSymbolHistogramCost + histogram.total_count() as super::util::floatX;
282282
}
283283
if count == 3i32 {
284-
let histo0: u32 = (*histogram).slice()[s[0]];
285-
let histo1: u32 = (*histogram).slice()[s[1]];
286-
let histo2: u32 = (*histogram).slice()[s[2]];
284+
let histo0: u32 = histogram.slice()[s[0]];
285+
let histo1: u32 = histogram.slice()[s[1]];
286+
let histo2: u32 = histogram.slice()[s[2]];
287287
let histomax: u32 = brotli_max_uint32_t(histo0, brotli_max_uint32_t(histo1, histo2));
288288
return kThreeSymbolHistogramCost
289289
+ (2u32).wrapping_mul(histo0.wrapping_add(histo1).wrapping_add(histo2))
@@ -296,7 +296,7 @@ pub fn BrotliPopulationCost<HistogramType: SliceWrapper<u32> + CostAccessors>(
296296
i = 0usize;
297297
while i < 4usize {
298298
{
299-
histo[i] = (*histogram).slice()[s[i]];
299+
histo[i] = histogram.slice()[s[i]];
300300
}
301301
i = i.wrapping_add(1);
302302
}
@@ -327,18 +327,18 @@ pub fn BrotliPopulationCost<HistogramType: SliceWrapper<u32> + CostAccessors>(
327327
// vectorization failed: it's faster to do things inline than split into two loops
328328
let mut nnz: usize = 0;
329329
let mut depth_histo = [0u32; 18];
330-
let total_count = (*histogram).total_count() as super::util::floatX;
331-
let log2total = FastLog2((*histogram).total_count() as u64);
330+
let total_count = histogram.total_count() as super::util::floatX;
331+
let log2total = FastLog2(histogram.total_count() as u64);
332332
i = 0usize;
333333
while i < data_size {
334-
if (*histogram).slice()[i] > 0u32 {
334+
if histogram.slice()[i] > 0u32 {
335335
let nnz_val = &mut nnz_data.slice_mut()[nnz >> 3];
336336
nnz_val[nnz & 7] = histogram.slice()[i] as i32;
337337
i += 1;
338338
nnz += 1;
339339
} else {
340340
let mut reps: u32 = 1;
341-
for hd in (*histogram).slice()[i + 1..data_size].iter() {
341+
for hd in histogram.slice()[i + 1..data_size].iter() {
342342
if *hd != 0 {
343343
break;
344344
}
@@ -368,7 +368,7 @@ pub fn BrotliPopulationCost<HistogramType: SliceWrapper<u32> + CostAccessors>(
368368
} else {
369369
let mut max_depth: usize = 1;
370370
let mut depth_histo = [0u32; 18];
371-
let log2total: super::util::floatX = FastLog2((*histogram).total_count() as u64); // 64 bit here
371+
let log2total: super::util::floatX = FastLog2(histogram.total_count() as u64); // 64 bit here
372372
let mut reps: u32 = 0;
373373
for histo in histogram.slice()[..data_size].iter() {
374374
if *histo != 0 {

src/enc/block_splitter.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ fn CopyLiteralsToByteArray(
170170
}
171171

172172
fn MyRand(seed: &mut u32) -> u32 {
173-
*seed = (*seed).wrapping_mul(16807);
173+
*seed = seed.wrapping_mul(16807);
174174
if *seed == 0u32 {
175175
*seed = 1u32;
176176
}
@@ -804,36 +804,36 @@ fn ClusterBlocks<
804804
<Alloc as Allocator<u32>>::free_cell(alloc, core::mem::take(&mut clusters));
805805
<Alloc as Allocator<HistogramType>>::free_cell(alloc, core::mem::take(&mut all_histograms));
806806
{
807-
if (*split).types_alloc_size() < num_blocks {
808-
let mut _new_size: usize = if (*split).types_alloc_size() == 0usize {
807+
if split.types_alloc_size() < num_blocks {
808+
let mut _new_size: usize = if split.types_alloc_size() == 0usize {
809809
num_blocks
810810
} else {
811-
(*split).types_alloc_size()
811+
split.types_alloc_size()
812812
};
813813
while _new_size < num_blocks {
814814
_new_size = _new_size.wrapping_mul(2);
815815
}
816816
let mut new_array = <Alloc as Allocator<u8>>::alloc_cell(alloc, _new_size);
817-
new_array.slice_mut()[..(*split).types_alloc_size()]
818-
.clone_from_slice(&split.types.slice()[..(*split).types_alloc_size()]);
817+
new_array.slice_mut()[..split.types_alloc_size()]
818+
.clone_from_slice(&split.types.slice()[..split.types_alloc_size()]);
819819
<Alloc as Allocator<u8>>::free_cell(
820820
alloc,
821821
core::mem::replace(&mut split.types, new_array),
822822
);
823823
}
824824
}
825825
{
826-
if (*split).lengths_alloc_size() < num_blocks {
827-
let mut _new_size: usize = if (*split).lengths_alloc_size() == 0usize {
826+
if split.lengths_alloc_size() < num_blocks {
827+
let mut _new_size: usize = if split.lengths_alloc_size() == 0usize {
828828
num_blocks
829829
} else {
830-
(*split).lengths_alloc_size()
830+
split.lengths_alloc_size()
831831
};
832832
while _new_size < num_blocks {
833833
_new_size = _new_size.wrapping_mul(2);
834834
}
835835
let mut new_array = <Alloc as Allocator<u32>>::alloc_cell(alloc, _new_size);
836-
new_array.slice_mut()[..(*split).lengths_alloc_size()]
836+
new_array.slice_mut()[..split.lengths_alloc_size()]
837837
.clone_from_slice(split.lengths.slice());
838838
<Alloc as Allocator<u32>>::free_cell(
839839
alloc,
@@ -904,38 +904,38 @@ fn SplitByteVector<
904904
return;
905905
} else if length < kMinLengthForBlockSplitting {
906906
{
907-
if (*split).types_alloc_size() < split.num_blocks.wrapping_add(1) {
908-
let mut _new_size: usize = if (*split).types_alloc_size() == 0usize {
907+
if split.types_alloc_size() < split.num_blocks.wrapping_add(1) {
908+
let mut _new_size: usize = if split.types_alloc_size() == 0usize {
909909
split.num_blocks.wrapping_add(1)
910910
} else {
911-
(*split).types_alloc_size()
911+
split.types_alloc_size()
912912
};
913913

914914
while _new_size < split.num_blocks.wrapping_add(1) {
915915
_new_size = _new_size.wrapping_mul(2);
916916
}
917917
let mut new_array = <Alloc as Allocator<u8>>::alloc_cell(alloc, _new_size);
918-
new_array.slice_mut()[..(*split).types_alloc_size()]
919-
.clone_from_slice(&split.types.slice()[..(*split).types_alloc_size()]);
918+
new_array.slice_mut()[..split.types_alloc_size()]
919+
.clone_from_slice(&split.types.slice()[..split.types_alloc_size()]);
920920
<Alloc as Allocator<u8>>::free_cell(
921921
alloc,
922922
core::mem::replace(&mut split.types, new_array),
923923
);
924924
}
925925
}
926926
{
927-
if (*split).lengths_alloc_size() < split.num_blocks.wrapping_add(1) {
928-
let mut _new_size: usize = if (*split).lengths_alloc_size() == 0usize {
927+
if split.lengths_alloc_size() < split.num_blocks.wrapping_add(1) {
928+
let mut _new_size: usize = if split.lengths_alloc_size() == 0usize {
929929
split.num_blocks.wrapping_add(1)
930930
} else {
931-
(*split).lengths_alloc_size()
931+
split.lengths_alloc_size()
932932
};
933933
while _new_size < split.num_blocks.wrapping_add(1) {
934934
_new_size = _new_size.wrapping_mul(2);
935935
}
936936
let mut new_array = <Alloc as Allocator<u32>>::alloc_cell(alloc, _new_size);
937-
new_array.slice_mut()[..(*split).lengths_alloc_size()]
938-
.clone_from_slice(&split.lengths.slice()[..(*split).lengths_alloc_size()]);
937+
new_array.slice_mut()[..split.lengths_alloc_size()]
938+
.clone_from_slice(&split.lengths.slice()[..split.lengths_alloc_size()]);
939939
<Alloc as Allocator<u32>>::free_cell(
940940
alloc,
941941
core::mem::replace(&mut split.lengths, new_array),

src/enc/brotli_bit_stream.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,7 +1900,7 @@ fn RunLengthCodeZeros(
19001900
if v[i] != 0u32 {
19011901
v[*out_size] = (v[i]).wrapping_add(*max_run_length_prefix);
19021902
i = i.wrapping_add(1);
1903-
*out_size = (*out_size).wrapping_add(1);
1903+
*out_size = out_size.wrapping_add(1);
19041904
} else {
19051905
let mut reps: u32 = 1u32;
19061906
let mut k: usize;
@@ -1917,7 +1917,7 @@ fn RunLengthCodeZeros(
19171917
let run_length_prefix: u32 = Log2FloorNonZero(reps as (u64));
19181918
let extra_bits: u32 = reps.wrapping_sub(1u32 << run_length_prefix);
19191919
v[*out_size] = run_length_prefix.wrapping_add(extra_bits << 9);
1920-
*out_size = (*out_size).wrapping_add(1);
1920+
*out_size = out_size.wrapping_add(1);
19211921
{
19221922
{
19231923
break;
@@ -1927,7 +1927,7 @@ fn RunLengthCodeZeros(
19271927
let extra_bits: u32 = (1u32 << max_prefix).wrapping_sub(1);
19281928
v[*out_size] = max_prefix.wrapping_add(extra_bits << 9);
19291929
reps = reps.wrapping_sub((2u32 << max_prefix).wrapping_sub(1));
1930-
*out_size = (*out_size).wrapping_add(1);
1930+
*out_size = out_size.wrapping_add(1);
19311931
}
19321932
}
19331933
}
@@ -2227,7 +2227,7 @@ fn CleanupBlockEncoder<Alloc: alloc::Allocator<u8> + alloc::Allocator<u16>>(
22272227
}
22282228

22292229
pub fn JumpToByteBoundary(storage_ix: &mut usize, storage: &mut [u8]) {
2230-
*storage_ix = (*storage_ix).wrapping_add(7u32 as usize) & !7u32 as usize;
2230+
*storage_ix = storage_ix.wrapping_add(7u32 as usize) & !7u32 as usize;
22312231
storage[(*storage_ix >> 3)] = 0u8;
22322232
}
22332233

@@ -3042,10 +3042,10 @@ pub fn BrotliStoreUncompressedMetaBlock<Cb, Alloc: BrotliAlloc>(
30423042
JumpToByteBoundary(storage_ix, storage);
30433043
let dst_start0 = (*storage_ix >> 3);
30443044
storage[dst_start0..(dst_start0 + input0.len())].clone_from_slice(input0);
3045-
*storage_ix = (*storage_ix).wrapping_add(input0.len() << 3);
3045+
*storage_ix = storage_ix.wrapping_add(input0.len() << 3);
30463046
let dst_start1 = (*storage_ix >> 3);
30473047
storage[dst_start1..(dst_start1 + input1.len())].clone_from_slice(input1);
3048-
*storage_ix = (*storage_ix).wrapping_add(input1.len() << 3);
3048+
*storage_ix = storage_ix.wrapping_add(input1.len() << 3);
30493049
BrotliWriteBitsPrepareStorage(*storage_ix, storage);
30503050
if params.log_meta_block && !suppress_meta_block_logging {
30513051
let cmds = [Command {

src/enc/cluster.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ fn BrotliCompareAndPushToQueue<
116116
/* Replace the top of the queue if needed. */
117117
if *num_pairs < max_num_pairs {
118118
pairs[*num_pairs] = pairs[0];
119-
*num_pairs = (*num_pairs).wrapping_add(1);
119+
*num_pairs = num_pairs.wrapping_add(1);
120120
}
121121
pairs[0] = p;
122122
} else if *num_pairs < max_num_pairs {
123123
pairs[*num_pairs] = p;
124-
*num_pairs = (*num_pairs).wrapping_add(1);
124+
*num_pairs = num_pairs.wrapping_add(1);
125125
}
126126
}
127127
}
@@ -279,12 +279,12 @@ pub fn BrotliHistogramBitCostDistance<
279279
candidate: &HistogramType,
280280
scratch_space: &mut HistogramType::i32vec,
281281
) -> super::util::floatX {
282-
if (*histogram).total_count() == 0usize {
282+
if histogram.total_count() == 0usize {
283283
0.0 as super::util::floatX
284284
} else {
285285
let mut tmp: HistogramType = histogram.clone();
286286
HistogramAddHistogram(&mut tmp, candidate);
287-
BrotliPopulationCost(&tmp, scratch_space) - (*candidate).bit_cost()
287+
BrotliPopulationCost(&tmp, scratch_space) - candidate.bit_cost()
288288
}
289289
}
290290

0 commit comments

Comments
 (0)