From 13259acbc3a9bf87db7245daf8132a7194264c51 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 28 Jan 2020 09:35:54 -0500 Subject: [PATCH] std.sort.insertionSort: remove superfluous block --- lib/std/sort.zig | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/std/sort.zig b/lib/std/sort.zig index 9fa7803cba..98bac0678d 100644 --- a/lib/std/sort.zig +++ b/lib/std/sort.zig @@ -7,16 +7,14 @@ const builtin = @import("builtin"); /// Stable in-place sort. O(n) best case, O(pow(n, 2)) worst case. O(1) memory (no allocator required). pub fn insertionSort(comptime T: type, items: []T, lessThan: fn (lhs: T, rhs: T) bool) void { - { - var i: usize = 1; - while (i < items.len) : (i += 1) { - const x = items[i]; - var j: usize = i; - while (j > 0 and lessThan(x, items[j - 1])) : (j -= 1) { - items[j] = items[j - 1]; - } - items[j] = x; + var i: usize = 1; + while (i < items.len) : (i += 1) { + const x = items[i]; + var j: usize = i; + while (j > 0 and lessThan(x, items[j - 1])) : (j -= 1) { + items[j] = items[j - 1]; } + items[j] = x; } }