Skip to content

Commit 516397f

Browse files
committed
make the dSt argument to sorting unsigned
1 parent 6fa4a9f commit 516397f

2 files changed

Lines changed: 15 additions & 16 deletions

File tree

libbz2-rs-sys/src/blocksort.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ fn mainSimpleSort(
447447
nblock: i32,
448448
lo: i32,
449449
hi: i32,
450-
d: i32,
450+
d: u32,
451451
budget: &mut i32,
452452
) {
453453
let bigN = hi - lo + 1;
@@ -461,8 +461,8 @@ fn mainSimpleSort(
461461
let v = ptr[i as usize];
462462
let mut j = i;
463463
while mainGtU(
464-
(ptr[(j - h) as usize]).wrapping_add(d as u32),
465-
v.wrapping_add(d as u32),
464+
(ptr[(j - h) as usize]).wrapping_add(d),
465+
v.wrapping_add(d),
466466
block,
467467
quadrant,
468468
nblock as u32,
@@ -500,7 +500,7 @@ fn median_of_3(mut a: u8, mut b: u8, mut c: u8) -> u8 {
500500
}
501501

502502
const MAIN_QSORT_SMALL_THRESH: i32 = 20;
503-
const MAIN_QSORT_DEPTH_THRESH: i32 = BZ_N_RADIX + BZ_N_QSORT;
503+
const MAIN_QSORT_DEPTH_THRESH: u32 = BZ_N_RADIX + BZ_N_QSORT;
504504
const MAIN_QSORT_STACK_SIZE: i32 = 100;
505505

506506
fn mainQSort3(
@@ -510,7 +510,7 @@ fn mainQSort3(
510510
nblock: i32,
511511
loSt: i32,
512512
hiSt: i32,
513-
dSt: i32,
513+
dSt: u32,
514514
budget: &mut i32,
515515
) {
516516
let mut unLo: i32;
@@ -521,7 +521,7 @@ fn mainQSort3(
521521
let mut m: i32;
522522
let mut med: i32;
523523

524-
let mut stack = [(0i32, 0i32, 0i32); 100];
524+
let mut stack = [(0i32, 0i32, 0u32); 100];
525525

526526
stack[0] = (loSt, hiSt, dSt);
527527

@@ -540,18 +540,17 @@ fn mainQSort3(
540540
}
541541
} else {
542542
med = median_of_3(
543-
block[(ptr[lo as usize]).wrapping_add(d as c_uint) as usize],
544-
block[(ptr[hi as usize]).wrapping_add(d as c_uint) as usize],
545-
block[((ptr[((lo + hi) >> 1) as usize]).wrapping_add(d as c_uint) as isize)
546-
as usize],
543+
block[(ptr[lo as usize]).wrapping_add(d) as usize],
544+
block[(ptr[hi as usize]).wrapping_add(d) as usize],
545+
block[((ptr[((lo + hi) >> 1) as usize]).wrapping_add(d) as isize) as usize],
547546
) as i32;
548547
ltLo = lo;
549548
unLo = ltLo;
550549
gtHi = hi;
551550
unHi = gtHi;
552551
loop {
553552
while unLo <= unHi {
554-
n = block[(ptr[unLo as usize]).wrapping_add(d as c_uint) as usize] as i32 - med;
553+
n = block[(ptr[unLo as usize]).wrapping_add(d) as usize] as i32 - med;
555554
match n.cmp(&0) {
556555
Ordering::Greater => break,
557556
Ordering::Equal => {
@@ -563,7 +562,7 @@ fn mainQSort3(
563562
}
564563
}
565564
while unLo <= unHi {
566-
n = block[(ptr[unHi as usize]).wrapping_add(d as c_uint) as usize] as i32 - med;
565+
n = block[(ptr[unHi as usize]).wrapping_add(d) as usize] as i32 - med;
567566
match n.cmp(&0) {
568567
Ordering::Less => break,
569568
Ordering::Equal => {
@@ -760,7 +759,7 @@ fn mainSort(
760759
hi - lo + 1 as c_int,
761760
);
762761
}
763-
mainQSort3(ptr, block, quadrant, nblock, lo, hi, 2 as c_int, budget);
762+
mainQSort3(ptr, block, quadrant, nblock, lo, hi, 2, budget);
764763
numQSorted += hi - lo + 1 as c_int;
765764
if *budget < 0 as c_int {
766765
return;

libbz2-rs-sys/src/bzlib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,9 @@ pub(crate) enum State {
443443
Input,
444444
}
445445

446-
pub(crate) const BZ_N_RADIX: i32 = 2;
447-
pub(crate) const BZ_N_QSORT: i32 = 12;
448-
pub(crate) const BZ_N_SHELL: i32 = 18;
446+
pub(crate) const BZ_N_RADIX: u32 = 2;
447+
pub(crate) const BZ_N_QSORT: u32 = 12;
448+
pub(crate) const BZ_N_SHELL: u32 = 18;
449449
pub(crate) const BZ_N_OVERSHOOT: usize = (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2) as usize;
450450

451451
pub(crate) const FTAB_LEN: usize = u16::MAX as usize + 2;

0 commit comments

Comments
 (0)