authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-28 09:35:54-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-28 16:22:09-05:00
log13259acbc3a9bf87db7245daf8132a7194264c51
treee536378926adc8ca183d2ed31eb7cc20e99fbd9a
parent76fba5baf9d582314b37c47561d76b7190f787a0
signature Commit is signed but in an unrecognized format.

std.sort.insertionSort: remove superfluous block


1 files changed, 7 insertions(+), 9 deletions(-)

lib/std/sort.zig+7-9
...@@ -7,16 +7,14 @@ const builtin = @import("builtin");...@@ -7,16 +7,14 @@ const builtin = @import("builtin");
77
8/// Stable in-place sort. O(n) best case, O(pow(n, 2)) worst case. O(1) memory (no allocator required).8/// Stable in-place sort. O(n) best case, O(pow(n, 2)) worst case. O(1) memory (no allocator required).
9pub fn insertionSort(comptime T: type, items: []T, lessThan: fn (lhs: T, rhs: T) bool) void {9pub fn insertionSort(comptime T: type, items: []T, lessThan: fn (lhs: T, rhs: T) bool) void {
10 {10 var i: usize = 1;
11 var i: usize = 1;11 while (i < items.len) : (i += 1) {
12 while (i < items.len) : (i += 1) {12 const x = items[i];
13 const x = items[i];13 var j: usize = i;
14 var j: usize = i;14 while (j > 0 and lessThan(x, items[j - 1])) : (j -= 1) {
15 while (j > 0 and lessThan(x, items[j - 1])) : (j -= 1) {15 items[j] = items[j - 1];
16 items[j] = items[j - 1];
17 }
18 items[j] = x;
19 }16 }
17 items[j] = x;
20 }18 }
21}19}
2220