Skip to content

Commit 7cbd844

Browse files
nyurikdanielrh
authored andcommitted
Remove explicit type for bitshifts
There is no point in using type qualifier for bitshift param: ``` foo >> 2i32 -> foo >> 2 ``` Replacing ``` (<<|>>) (\d+)[ui](size|\d+) ``` with `$1 $2`
1 parent 22bd45b commit 7cbd844

17 files changed

+222
-230
lines changed

corrosion/backward_references_hq.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub unsafe extern fn ctzll(mut x : usize) -> usize {
6767
let mut count : u8 = 0u8;
6868
while x & 0usize != 0 {
6969
count = (count as i32 + 1i32) as u8;
70-
x = x >> 1i32;
70+
x = x >> 1;
7171
}
7272
count as usize
7373
}
@@ -78,17 +78,17 @@ static kCutoffTransformsCount : u32 = 10u32;
7878

7979
static kCutoffTransforms
8080
: usize
81-
= 0x71b520ausize << 32i32 | 0xda2d3200u32 as usize;
81+
= 0x71b520ausize << 32 | 0xda2d3200u32 as usize;
8282

8383
static kHashMul32 : u32 = 0x1e35a7bdu32;
8484

8585
static kHashMul64
8686
: usize
87-
= 0x1e35a7bdusize << 32i32 | 0x1e35a7bdusize;
87+
= 0x1e35a7bdusize << 32 | 0x1e35a7bdusize;
8888

8989
static kHashMul64Long
9090
: usize
91-
= 0x1fe35a7bu32 as usize << 32i32 | 0xd3579bd3u32 as usize;
91+
= 0x1fe35a7bu32 as usize << 32 | 0xd3579bd3u32 as usize;
9292

9393
static kInfinity : f32 = 1.7e38f32;
9494

@@ -219,7 +219,7 @@ unsafe extern fn ZopfliNodeCopyDistance(
219219
unsafe extern fn ZopfliNodeLengthCode(
220220
mut self : *const ZopfliNode
221221
) -> u32 {
222-
let modifier : u32 = (*self).length >> 25i32;
222+
let modifier : u32 = (*self).length >> 25;
223223
ZopfliNodeCopyLength(self).wrapping_add(9).wrapping_sub(
224224
modifier
225225
)
@@ -234,7 +234,7 @@ unsafe extern fn brotli_min_size_t(
234234
unsafe extern fn ZopfliNodeDistanceCode(
235235
mut self : *const ZopfliNode
236236
) -> u32 {
237-
let short_code : u32 = (*self).dcode_insert_length >> 27i32;
237+
let short_code : u32 = (*self).dcode_insert_length >> 27;
238238
if short_code == 0u32 {
239239
ZopfliNodeCopyDistance(self).wrapping_add(
240240
16u32
@@ -249,7 +249,7 @@ unsafe extern fn ZopfliNodeDistanceCode(
249249
unsafe extern fn Log2FloorNonZero(mut n : usize) -> u32 {
250250
let mut result : u32 = 0u32;
251251
while {
252-
n = n >> 1i32;
252+
n = n >> 1;
253253
n
254254
} != 0 {
255255
result = result.wrapping_add(1);
@@ -290,7 +290,7 @@ unsafe extern fn PrefixEncodeCopyDistance(
290290
: usize
291291
= (2usize).wrapping_add(prefix) << bucket;
292292
let mut nbits : usize = bucket.wrapping_sub(postfix_bits);
293-
*code = (nbits << 10i32 | (16usize).wrapping_add(
293+
*code = (nbits << 10 | (16usize).wrapping_add(
294294
num_direct_codes
295295
).wrapping_add(
296296
(2usize).wrapping_mul(
@@ -318,7 +318,7 @@ unsafe extern fn GetInsertLengthCode(
318318
).wrapping_sub(
319319
1u32
320320
);
321-
((nbits << 1i32) as usize).wrapping_add(
321+
((nbits << 1) as usize).wrapping_add(
322322
insertlen.wrapping_sub(2) >> nbits
323323
).wrapping_add(
324324
2usize
@@ -349,7 +349,7 @@ unsafe extern fn GetCopyLengthCode(mut copylen : usize) -> u16 {
349349
).wrapping_sub(
350350
1u32
351351
);
352-
((nbits << 1i32) as usize).wrapping_add(
352+
((nbits << 1) as usize).wrapping_add(
353353
copylen.wrapping_sub(6) >> nbits
354354
).wrapping_add(
355355
4usize
@@ -370,7 +370,7 @@ unsafe extern fn CombineLengthCodes(
370370
) -> u16 {
371371
let mut bits64
372372
: u16
373-
= (copycode as u32 & 0x7u32 | (inscode as u32 & 0x7u32) << 3i32) as u16;
373+
= (copycode as u32 & 0x7u32 | (inscode as u32 & 0x7u32) << 3) as u16;
374374
if use_last_distance != 0 && (inscode as i32 < 8i32) && (copycode as i32 < 16i32) {
375375
if copycode as i32 < 8i32 {
376376
bits64 as i32
@@ -380,8 +380,8 @@ unsafe extern fn CombineLengthCodes(
380380
} else {
381381
let mut offset
382382
: i32
383-
= 2i32 * ((copycode as i32 >> 3i32) + 3i32 * (inscode as i32 >> 3i32));
384-
offset = (offset << 5i32) + 0x40i32 + (0x520d40i32 >> offset & 0xc0i32);
383+
= 2i32 * ((copycode as i32 >> 3) + 3i32 * (inscode as i32 >> 3));
384+
offset = (offset << 5) + 0x40i32 + (0x520d40i32 >> offset & 0xc0i32);
385385
(offset as u16 as i32 | bits64 as i32) as u16
386386
}
387387
}
@@ -407,7 +407,7 @@ unsafe extern fn InitCommand(
407407
) {
408408
let mut delta : u32 = copylen_code_delta as i8 as u8 as u32;
409409
(*self).insert_len_ = insertlen as u32;
410-
(*self).copy_len_ = (copylen | (delta << 25i32) as usize) as u32;
410+
(*self).copy_len_ = (copylen | (delta << 25) as usize) as u32;
411411
PrefixEncodeCopyDistance(
412412
distance_code,
413413
(*dist).num_direct_distance_codes as usize,
@@ -689,7 +689,7 @@ unsafe extern fn FindMatchLengthWithLimit(
689689
let mut matched : usize = 0usize;
690690
let mut limit2
691691
: usize
692-
= (limit >> 3i32).wrapping_add(1);
692+
= (limit >> 3).wrapping_add(1);
693693
while {
694694
limit2 = limit2.wrapping_sub(1);
695695
limit2
@@ -710,7 +710,7 @@ unsafe extern fn FindMatchLengthWithLimit(
710710
s1.offset(matched as isize) as (*const std::os::raw::c_void)
711711
);
712712
let mut matching_bits : usize = ctzll(x) as usize;
713-
matched = matched.wrapping_add(matching_bits >> 3i32);
713+
matched = matched.wrapping_add(matching_bits >> 3);
714714
return matched;
715715
}
716716
}
@@ -733,7 +733,7 @@ unsafe extern fn InitBackwardMatch(
733733
mut self : *mut BackwardMatch, mut dist : usize, mut len : usize
734734
) {
735735
(*self).distance = dist as u32;
736-
(*self).length_and_code = (len << 5i32) as u32;
736+
(*self).length_and_code = (len << 5) as u32;
737737
}
738738

739739
#[derive(Clone, Copy)]
@@ -758,7 +758,7 @@ unsafe extern fn HashBytesH10(mut data : *const u8) -> u32 {
758758
).wrapping_mul(
759759
kHashMul32
760760
);
761-
h >> 32i32 - 17i32
761+
h >> 32 - 17i32
762762
}
763763

764764
unsafe extern fn ForestH10(mut self : *mut H10) -> *mut u32 {
@@ -932,7 +932,7 @@ unsafe extern fn InitDictionaryBackwardMatch(
932932
mut len_code : usize
933933
) {
934934
(*self).distance = dist as u32;
935-
(*self).length_and_code = (len << 5i32 | if len == len_code {
935+
(*self).length_and_code = (len << 5 | if len == len_code {
936936
0usize
937937
} else {
938938
len_code
@@ -1063,7 +1063,7 @@ unsafe extern fn FindAllMatchesH10(
10631063
let mut distance
10641064
: usize
10651065
= max_backward.wrapping_add(gap).wrapping_add(
1066-
(dict_id >> 5i32) as usize
1066+
(dict_id >> 5) as usize
10671067
).wrapping_add(
10681068
1usize
10691069
);
@@ -1094,7 +1094,7 @@ unsafe extern fn FindAllMatchesH10(
10941094
unsafe extern fn BackwardMatchLength(
10951095
mut self : *const BackwardMatch
10961096
) -> usize {
1097-
((*self).length_and_code >> 5i32) as usize
1097+
((*self).length_and_code >> 5) as usize
10981098
}
10991099

11001100
unsafe extern fn MaxZopfliCandidates(
@@ -1377,9 +1377,9 @@ unsafe extern fn UpdateZopfliNode(
13771377
9u32 as usize
13781378
).wrapping_sub(
13791379
len_code
1380-
) << 25i32) as u32;
1380+
) << 25) as u32;
13811381
(*next).distance = dist as u32;
1382-
(*next).dcode_insert_length = (short_code << 27i32 | pos.wrapping_sub(
1382+
(*next).dcode_insert_length = (short_code << 27 | pos.wrapping_sub(
13831383
start_pos
13841384
)) as u32;
13851385
(*next).u.cost = cost;
@@ -1605,7 +1605,7 @@ unsafe extern fn UpdateNodes(
16051605
&mut dist_symbol as (*mut u16),
16061606
&mut distextra as (*mut u32)
16071607
);
1608-
distnumextra = (dist_symbol as i32 >> 10i32) as u32;
1608+
distnumextra = (dist_symbol as i32 >> 10) as u32;
16091609
dist_cost = base_cost + distnumextra as (f32) + ZopfliCostModelGetDistanceCost(
16101610
model,
16111611
(dist_symbol as i32 & 0x3ffi32) as usize

corrosion/backward_references_hq_safe.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub fn ctzll(mut x : usize) -> usize {
6767
let mut count : u8 = 0u8;
6868
while x & 0usize != 0 {
6969
count = (count as i32 + 1i32) as u8;
70-
x = x >> 1i32;
70+
x = x >> 1;
7171
}
7272
count as usize
7373
}
@@ -78,17 +78,17 @@ static kCutoffTransformsCount : u32 = 10u32;
7878

7979
static kCutoffTransforms
8080
: usize
81-
= 0x71b520ausize << 32i32 | 0xda2d3200u32 as usize;
81+
= 0x71b520ausize << 32 | 0xda2d3200u32 as usize;
8282

8383
static kHashMul32 : u32 = 0x1e35a7bdu32;
8484

8585
static kHashMul64
8686
: usize
87-
= 0x1e35a7bdusize << 32i32 | 0x1e35a7bdusize;
87+
= 0x1e35a7bdusize << 32 | 0x1e35a7bdusize;
8888

8989
static kHashMul64Long
9090
: usize
91-
= 0x1fe35a7bu32 as usize << 32i32 | 0xd3579bd3u32 as usize;
91+
= 0x1fe35a7bu32 as usize << 32 | 0xd3579bd3u32 as usize;
9292

9393
static kInfinity : f32 = 1.7e38f32;
9494

@@ -219,7 +219,7 @@ fn ZopfliNodeCopyDistance(
219219
fn ZopfliNodeLengthCode(
220220
mut xself : & ZopfliNode
221221
) -> u32 {
222-
let modifier : u32 = (*xself).length >> 25i32;
222+
let modifier : u32 = (*xself).length >> 25;
223223
ZopfliNodeCopyLength(xself).wrapping_add(9).wrapping_sub(
224224
modifier
225225
)
@@ -234,7 +234,7 @@ fn brotli_min_size_t(
234234
fn ZopfliNodeDistanceCode(
235235
mut xself : & ZopfliNode
236236
) -> u32 {
237-
let short_code : u32 = (*xself).dcode_insert_length >> 27i32;
237+
let short_code : u32 = (*xself).dcode_insert_length >> 27;
238238
if short_code == 0u32 {
239239
ZopfliNodeCopyDistance(xself).wrapping_add(
240240
16u32
@@ -249,7 +249,7 @@ fn ZopfliNodeDistanceCode(
249249
fn Log2FloorNonZero(mut n : usize) -> u32 {
250250
let mut result : u32 = 0u32;
251251
while {
252-
n = n >> 1i32;
252+
n = n >> 1;
253253
n
254254
} != 0 {
255255
result = result.wrapping_add(1);
@@ -290,7 +290,7 @@ fn PrefixEncodeCopyDistance(
290290
: usize
291291
= (2usize).wrapping_add(prefix) << bucket;
292292
let mut nbits : usize = bucket.wrapping_sub(postfix_bits);
293-
*code = (nbits << 10i32 | (16usize).wrapping_add(
293+
*code = (nbits << 10 | (16usize).wrapping_add(
294294
num_direct_codes
295295
).wrapping_add(
296296
(2usize).wrapping_mul(
@@ -318,7 +318,7 @@ fn GetInsertLengthCode(
318318
).wrapping_sub(
319319
1u32
320320
);
321-
((nbits << 1i32) as usize).wrapping_add(
321+
((nbits << 1) as usize).wrapping_add(
322322
insertlen.wrapping_sub(2) >> nbits
323323
).wrapping_add(
324324
2usize
@@ -349,7 +349,7 @@ fn GetCopyLengthCode(mut copylen : usize) -> u16 {
349349
).wrapping_sub(
350350
1u32
351351
);
352-
((nbits << 1i32) as usize).wrapping_add(
352+
((nbits << 1) as usize).wrapping_add(
353353
copylen.wrapping_sub(6) >> nbits
354354
).wrapping_add(
355355
4usize
@@ -370,7 +370,7 @@ fn CombineLengthCodes(
370370
) -> u16 {
371371
let mut bits64
372372
: u16
373-
= (copycode as u32 & 0x7u32 | (inscode as u32 & 0x7u32) << 3i32) as u16;
373+
= (copycode as u32 & 0x7u32 | (inscode as u32 & 0x7u32) << 3) as u16;
374374
if use_last_distance != 0 && (inscode as i32 < 8i32) && (copycode as i32 < 16i32) {
375375
if copycode as i32 < 8i32 {
376376
bits64 as i32
@@ -380,8 +380,8 @@ fn CombineLengthCodes(
380380
} else {
381381
let mut offset
382382
: i32
383-
= 2i32 * ((copycode as i32 >> 3i32) + 3i32 * (inscode as i32 >> 3i32));
384-
offset = (offset << 5i32) + 0x40i32 + (0x520d40i32 >> offset & 0xc0i32);
383+
= 2i32 * ((copycode as i32 >> 3) + 3i32 * (inscode as i32 >> 3));
384+
offset = (offset << 5) + 0x40i32 + (0x520d40i32 >> offset & 0xc0i32);
385385
(offset as u16 as i32 | bits64 as i32) as u16
386386
}
387387
}
@@ -407,7 +407,7 @@ fn InitCommand(
407407
) {
408408
let mut delta : u32 = copylen_code_delta as i8 as u8 as u32;
409409
(*xself).insert_len_ = insertlen as u32;
410-
(*xself).copy_len_ = (copylen | (delta << 25i32) as usize) as u32;
410+
(*xself).copy_len_ = (copylen | (delta << 25) as usize) as u32;
411411
PrefixEncodeCopyDistance(
412412
distance_code,
413413
(*dist).num_direct_distance_codes as usize,
@@ -689,7 +689,7 @@ fn FindMatchLengthWithLimit(
689689
let mut matched : usize = 0usize;
690690
let mut limit2
691691
: usize
692-
= (limit >> 3i32).wrapping_add(1);
692+
= (limit >> 3).wrapping_add(1);
693693
while {
694694
limit2 = limit2.wrapping_sub(1);
695695
limit2
@@ -710,7 +710,7 @@ fn FindMatchLengthWithLimit(
710710
s1[(matched as usize) ..]
711711
);
712712
let mut matching_bits : usize = ctzll(x) as usize;
713-
matched = matched.wrapping_add(matching_bits >> 3i32);
713+
matched = matched.wrapping_add(matching_bits >> 3);
714714
return matched;
715715
}
716716
}
@@ -733,7 +733,7 @@ fn InitBackwardMatch(
733733
mut xself : &mut BackwardMatch, mut dist : usize, mut len : usize
734734
) {
735735
(*xself).distance = dist as u32;
736-
(*xself).length_and_code = (len << 5i32) as u32;
736+
(*xself).length_and_code = (len << 5) as u32;
737737
}
738738

739739

@@ -758,7 +758,7 @@ fn HashBytesH10(mut data : & [u8]) -> u32 {
758758
).wrapping_mul(
759759
kHashMul32
760760
);
761-
h >> 32i32 - 17i32
761+
h >> 32 - 17i32
762762
}
763763

764764
fn ForestH10(mut xself : &mut H10) -> *mut u32 {
@@ -932,7 +932,7 @@ fn InitDictionaryBackwardMatch(
932932
mut len_code : usize
933933
) {
934934
(*xself).distance = dist as u32;
935-
(*xself).length_and_code = (len << 5i32 | if len == len_code {
935+
(*xself).length_and_code = (len << 5 | if len == len_code {
936936
0usize
937937
} else {
938938
len_code
@@ -1063,7 +1063,7 @@ fn FindAllMatchesH10(
10631063
let mut distance
10641064
: usize
10651065
= max_backward.wrapping_add(gap).wrapping_add(
1066-
(dict_id >> 5i32) as usize
1066+
(dict_id >> 5) as usize
10671067
).wrapping_add(
10681068
1
10691069
);
@@ -1094,7 +1094,7 @@ fn FindAllMatchesH10(
10941094
fn BackwardMatchLength(
10951095
mut xself : & BackwardMatch
10961096
) -> usize {
1097-
((*xself).length_and_code >> 5i32) as usize
1097+
((*xself).length_and_code >> 5) as usize
10981098
}
10991099

11001100
fn MaxZopfliCandidates(
@@ -1372,9 +1372,9 @@ fn GetInsertExtra(mut inscode : u16) -> u32 {
13721372
9u32 as usize
13731373
).wrapping_sub(
13741374
len_code
1375-
) << 25i32) as u32;
1375+
) << 25) as u32;
13761376
(*next).distance = dist as u32;
1377-
(*next).dcode_insert_length = (short_code << 27i32 | pos.wrapping_sub(
1377+
(*next).dcode_insert_length = (short_code << 27 | pos.wrapping_sub(
13781378
start_pos
13791379
)) as u32;
13801380
(*next).u.cost = cost;
@@ -1600,7 +1600,7 @@ fn UpdateNodes(
16001600
&mut dist_symbol ,
16011601
&mut distextra
16021602
);
1603-
distnumextra = (dist_symbol as i32 >> 10i32) as u32;
1603+
distnumextra = (dist_symbol as i32 >> 10) as u32;
16041604
dist_cost = base_cost + distnumextra as (f32) + ZopfliCostModelGetDistanceCost(
16051605
model,
16061606
(dist_symbol as i32 & 0x3ffi32) as usize

0 commit comments

Comments
 (0)