Skip to content

Commit 8e6d209

Browse files
committed
Remove and comment out more MergeState code
1 parent 046460c commit 8e6d209

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

src/libstd/sort.rs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -353,17 +353,17 @@ struct RunState {
353353

354354
struct MergeState<T> {
355355
mut min_gallop: uint,
356-
mut mergePt: uint,
357-
mut tmpPt: uint,
356+
//mut mergePt: uint,
357+
//mut tmpPt: uint,
358358
mut array: &[mut T],
359359
runs: DVec<RunState>,
360360
}
361361

362362
fn MergeState<T>() -> MergeState<T> {
363363
MergeState {
364364
min_gallop: MIN_GALLOP,
365-
mergePt: 0,
366-
tmpPt: 0,
365+
//mergePt: 0,
366+
//tmpPt: 0,
367367
array: &[mut],
368368
runs: DVec(),
369369
}
@@ -427,13 +427,13 @@ impl<T: Copy Ord> MergeState<T> {
427427
}
428428

429429
let slice = vec::mut_view(array, b1, b1+l1);
430-
self.mergePt = b1;
430+
//self.mergePt = b1;
431431
let k = gallop_right(&const array[b2], slice, 0);
432432
b1 += k;
433433
l1 -= k;
434434
if l1 != 0 {
435435
let slice = vec::mut_view(array, b2, b2+l2);
436-
self.mergePt = b2;
436+
//self.mergePt = b2;
437437
let l2 = gallop_left(
438438
&const array[b1+l1-1],slice,l2-1);
439439
if l2 > 0 {
@@ -446,16 +446,16 @@ impl<T: Copy Ord> MergeState<T> {
446446
}
447447
}
448448
self.runs.pop();
449-
self.mergePt = 0;
449+
//self.mergePt = 0;
450450
}
451451

452452
fn merge_lo(&self, array: &[mut T], base1: uint, len1: uint,
453453
base2: uint, len2: uint) {
454454
assert len1 != 0 && len2 != 0 && base1+len1 == base2;
455455

456456
let tmp = vec::to_mut(vec::slice(array, base1, base1+len1));
457-
self.tmpPt = 0;
458-
self.mergePt = base1;
457+
//self.tmpPt = 0;
458+
//self.mergePt = base1;
459459

460460
let mut c1 = 0;
461461
let mut c2 = base2;
@@ -465,7 +465,7 @@ impl<T: Copy Ord> MergeState<T> {
465465

466466
array[dest] <-> array[c2];
467467
dest += 1; c2 += 1; len2 -= 1;
468-
self.mergePt += 1;
468+
//self.mergePt += 1;
469469

470470
if len2 == 0 {
471471
copy_vec(array, dest, tmp, 0, len1);
@@ -488,16 +488,16 @@ impl<T: Copy Ord> MergeState<T> {
488488
if array[c2] < tmp[c1] {
489489
array[dest] <-> array[c2];
490490
dest += 1; c2 += 1; len2 -= 1;
491-
self.mergePt += 1;
491+
//self.mergePt += 1;
492492
count2 += 1; count1 = 0;
493493
if len2 == 0 {
494494
break_outer = true;
495495
}
496496
} else {
497497
array[dest] <-> tmp[c1];
498498
dest += 1; c1 += 1; len1 -= 1;
499-
self.mergePt += 1;
500-
self.tmpPt += 1;
499+
//self.mergePt += 1;
500+
//self.tmpPt += 1;
501501
count1 += 1; count2 = 0;
502502
if len1 == 1 {
503503
break_outer = true;
@@ -519,25 +519,25 @@ impl<T: Copy Ord> MergeState<T> {
519519
if count1 != 0 {
520520
copy_vec(array, dest, tmp, c1, count1);
521521
dest += count1; c1 += count1; len1 -= count1;
522-
self.mergePt += count1; self.tmpPt += count1;
522+
//self.mergePt += count1; self.tmpPt += count1;
523523
if len1 <= 1 { break_outer = true; break; }
524524
}
525525
array[dest] <-> array[c2];
526526
dest += 1; c2 += 1; len2 -= 1;
527-
self.mergePt += 1;
527+
//self.mergePt += 1;
528528
if len2 == 0 { break_outer = true; break; }
529529

530530
let tmp_view = vec::const_view(array, c2, c2+len2);
531531
count2 = gallop_left(&const tmp[c1], tmp_view, 0);
532532
if count2 != 0 {
533533
copy_vec(array, dest, array, c2, count2);
534534
dest += count2; c2 += count2; len2 -= count2;
535-
self.mergePt += count2;
535+
//self.mergePt += count2;
536536
if len2 == 0 { break_outer = true; break; }
537537
}
538538
array[dest] <-> tmp[c1];
539539
dest += 1; c1 += 1; len1 -= 1;
540-
self.mergePt += 1; self.tmpPt += 1;
540+
//self.mergePt += 1; self.tmpPt += 1;
541541
if len1 == 1 { break_outer = true; break; }
542542
min_gallop -= 1;
543543
if !(count1 >= MIN_GALLOP || count2 >= MIN_GALLOP) {
@@ -561,7 +561,7 @@ impl<T: Copy Ord> MergeState<T> {
561561
assert len1 > 1;
562562
copy_vec(array, dest, tmp, c1, len1);
563563
}
564-
self.tmpPt = 0;
564+
//self.tmpPt = 0;
565565
}
566566
567567
fn merge_hi(&self, array: &[mut T], base1: uint, len1: uint,
@@ -576,8 +576,8 @@ impl<T: Copy Ord> MergeState<T> {
576576
let mut len1 = len1;
577577
let mut len2 = len2;
578578
579-
self.mergePt = dest;
580-
self.tmpPt = len2 - 1;
579+
//self.mergePt = dest;
580+
//self.tmpPt = len2 - 1;
581581
582582
array[dest] <-> array[c1];
583583
dest -= 1; c1 -= 1; len1 -= 1;
@@ -605,15 +605,15 @@ impl<T: Copy Ord> MergeState<T> {
605605
if tmp[c2] < array[c1] {
606606
array[dest] <-> array[c1];
607607
dest -= 1; c1 -= 1; len1 -= 1;
608-
self.mergePt -= 1;
608+
//self.mergePt -= 1;
609609
count1 += 1; count2 = 0;
610610
if len1 == 0 {
611611
break_outer = true;
612612
}
613613
} else {
614614
array[dest] <-> tmp[c2];
615615
dest -= 1; c2 -= 1; len2 -= 1;
616-
self.mergePt -= 1; self.tmpPt -= 1;
616+
//self.mergePt -= 1; self.tmpPt -= 1;
617617
count2 += 1; count1 = 0;
618618
if len2 == 1 {
619619
break_outer = true;
@@ -635,28 +635,28 @@ impl<T: Copy Ord> MergeState<T> {
635635
636636
if count1 != 0 {
637637
dest -= count1; c1 -= count1; len1 -= count1;
638-
self.mergePt -= count1;
638+
//self.mergePt -= count1;
639639
copy_vec(array, dest+1, array, c1+1, count1);
640640
if len1 == 0 { break_outer = true; break; }
641641
}
642642
643643
array[dest] <-> tmp[c2];
644644
dest -= 1; c2 -= 1; len2 -= 1;
645-
self.mergePt -= 1; self.tmpPt -= 1;
645+
//self.mergePt -= 1; self.tmpPt -= 1;
646646
if len2 == 1 { break_outer = true; break; }
647647
648648
//let tmp_view = vec::mut_view(tmp, 0, len2);
649649
let count2 = len2 - gallop_left(&const array[c1],
650650
vec::mut_view(tmp, 0, len2), len2-1);
651651
if count2 != 0 {
652652
dest -= count2; c2 -= count2; len2 -= count2;
653-
self.mergePt -= count2; self.tmpPt -= count2;
653+
//self.mergePt -= count2; self.tmpPt -= count2;
654654
copy_vec(array, dest+1, tmp, c2+1, count2);
655655
if len2 <= 1 { break_outer = true; break; }
656656
}
657657
array[dest] <-> array[c1];
658658
dest -= 1; c1 -= 1; len1 -= 1;
659-
self.mergePt -= 1;
659+
//self.mergePt -= 1;
660660
if len1 == 0 { break_outer = true; break; }
661661
min_gallop -= 1;
662662
if !(count1 >= MIN_GALLOP || count2 >= MIN_GALLOP) {
@@ -683,7 +683,7 @@ impl<T: Copy Ord> MergeState<T> {
683683
assert len2 != 0;
684684
copy_vec(array, dest-(len2-1), tmp, 0, len2);
685685
}
686-
self.tmpPt = 0;
686+
//self.tmpPt = 0;
687687
}
688688

689689
fn merge_collapse(&self, array: &[mut T]) {
@@ -1139,7 +1139,7 @@ mod big_tests {
11391139
arr[idx] = @rng.gen_float();
11401140
}
11411141
tim_sort(arr);
1142-
isSorted(arr, 1);
1142+
isSorted(arr);
11431143

11441144
let arr = if n > 4 {
11451145
let part = vec::view(arr, 0, 4);

0 commit comments

Comments
 (0)