From f34c4f4b040c1a7b086f1551141ee65f4af0dd48 Mon Sep 17 00:00:00 2001 From: Simon BD Date: Thu, 27 Sep 2012 20:44:14 -0500 Subject: [PATCH] Remove trailing whitespace --- src/libstd/sort.rs | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index e0e35f68da2..47b66fc17b2 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -206,9 +206,9 @@ fn timsort(array: &[mut T]) { idx += runLen; remaining -= runLen; - if remaining == 0 { break; } + if remaining == 0 { break; } } - + ms.mergeForceCollapse(array); } @@ -288,18 +288,18 @@ fn countRunAndMakeAscending(array: &[mut T]) -> uint { run += 1; } } - + return run; } pure fn gallopLeft(key: &const T, array: &[const T], - hint: uint) -> uint { + hint: uint) -> uint { let size = array.len(); assert size != 0 && hint < size; let mut lastOfs = 0; let mut ofs = 1; - + if *key > array[hint] { // Gallop right until array[hint+lastOfs] < key <= array[hint+ofs] let maxOfs = size - hint; @@ -319,7 +319,7 @@ fn countRunAndMakeAscending(array: &[mut T]) -> uint { ofs = (ofs << 1) + 1; if ofs < lastOfs { ofs = maxOfs; } // uint overflow guard } - + if ofs > maxOfs { ofs = maxOfs; } let tmp = lastOfs; @@ -348,7 +348,7 @@ fn countRunAndMakeAscending(array: &[mut T]) -> uint { let mut lastOfs = 0; let mut ofs = 1; - + if *key >= array[hint] { // Gallop right until array[hint+lastOfs] <= key < array[hint+ofs] let maxOfs = size - hint; @@ -360,7 +360,7 @@ fn countRunAndMakeAscending(array: &[mut T]) -> uint { if ofs > maxOfs { ofs = maxOfs; } lastOfs += hint; - ofs += hint; + ofs += hint; } else { // Gallop left until array[hint-ofs] <= key < array[hint-lastOfs] let maxOfs = hint + 1; @@ -411,7 +411,7 @@ struct MergeState { fn MergeState() -> MergeState { let mut tmp = ~[]; - vec::reserve(&mut tmp, INITIAL_TMP_STORAGE); + vec::reserve(&mut tmp, INITIAL_TMP_STORAGE); MergeState { minGallop: MIN_GALLOP, tmp: tmp, @@ -469,7 +469,7 @@ fn mergeAt(n: uint, array: &[mut T]) { fn mergeLo(array: &[mut T], base1: uint, len1: uint, base2: uint, len2: uint) { assert len1 != 0 && len2 != 0 && base1+len1 == base2; - + vec::reserve(&mut self.tmp, len1); unsafe { @@ -563,7 +563,7 @@ fn mergeLo(array: &[mut T], base1: uint, len1: uint, minGallop -= 1; if !(count1 >= MIN_GALLOP || count2 >= MIN_GALLOP) { break; - } + } } if breakOuter { break; } if minGallop < 0 { minGallop = 0; } @@ -655,7 +655,7 @@ fn mergeHi(array: &[mut T], base1: uint, len1: uint, } } if breakOuter { break; } - + // Start to gallop loop { assert len2 > 1 && len1 != 0; @@ -692,15 +692,15 @@ fn mergeHi(array: &[mut T], base1: uint, len1: uint, minGallop -= 1; if !(count1 >= MIN_GALLOP || count2 >= MIN_GALLOP) { break; - } + } } - + if breakOuter { break; } if minGallop < 0 { minGallop = 0; } minGallop += 2; // Penalize for leaving gallop } self.minGallop = if minGallop < 1 { 1 } else { minGallop }; - + if len2 == 1 { assert len1 > 0; dest -= len1; @@ -757,8 +757,8 @@ fn mergeForceCollapse(array: &[mut T]) { // Moves elements to from dest to from // Unsafe as it makes the from parameter invalid between s2 and s2+len #[inline(always)] -unsafe fn moveVec(dest: &[mut T], s1: uint, - from: &[const T], s2: uint, len: uint) { +unsafe fn moveVec(dest: &[mut T], s1: uint, + from: &[const T], s2: uint, len: uint) { assert s1+len <= dest.len() && s2+len <= from.len(); do vec::as_mut_buf(dest) |p, _len| { @@ -818,7 +818,7 @@ mod test_qsort { fn check_sort(v1: &[mut int], v2: &[mut int]) { let len = vec::len::(v1); pure fn leual(a: &int, b: &int) -> bool { *a <= *b } - quick_sort::(leual, v1); + quick_sort::(v1, leual); let mut i = 0u; while i < len { log(debug, v2[i]); @@ -859,7 +859,7 @@ fn test_simple() { let expected = ~[1, 2, 3]; - sort::quick_sort(|x, y| { int::le(*x, *y) }, names); + do sort::quick_sort(names) |x, y| { int::le(*x, *y) }; let immut_names = vec::from_mut(names); @@ -880,7 +880,7 @@ fn check_sort(v1: &[int], v2: &[int]) { let len = vec::len::(v1); pure fn le(a: &int, b: &int) -> bool { *a <= *b } let f = le; - let v3 = merge_sort::(f, v1); + let v3 = merge_sort::(v1, f); let mut i = 0u; while i < len { log(debug, v3[i]); @@ -910,7 +910,7 @@ fn test() { fn test_merge_sort_mutable() { pure fn le(a: &int, b: &int) -> bool { *a <= *b } let v1 = ~[mut 3, 2, 1]; - let v2 = merge_sort(le, v1); + let v2 = merge_sort(v1, le); assert v2 == ~[1, 2, 3]; } @@ -932,7 +932,7 @@ fn test_merge_sort_stability() "Sally Mae", "JOE BOB", "Alex Andy"]; let names2 = ~["Alex Andy", "Jack Brown", "joe bob", "Joe Bob", "JOE Bob", "JOE BOB", "Sally Mae"]; - let names3 = merge_sort(ile, names1); + let names3 = merge_sort(names1, ile); assert names3 == names2; } }