From ad26bb5e3098cbfd7c0ad9a1dc9d38c92e50f06e Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 4 Oct 2016 03:01:09 +0000 Subject: all: use sort.Slice where applicable I avoided anywhere in the compiler or things which might be used by the compiler in the future, since they need to build with Go 1.4. I also avoided anywhere where there was no benefit to changing it. I probably missed some. Updates #16721 Change-Id: Ib3c895ff475c6dec2d4322393faaf8cb6a6d4956 Reviewed-on: https://go-review.googlesource.com/30250 TryBot-Result: Gobot Gobot Run-TryBot: Brad Fitzpatrick Reviewed-by: Andrew Gerrand --- src/runtime/debug/garbage.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/runtime/debug') diff --git a/src/runtime/debug/garbage.go b/src/runtime/debug/garbage.go index 8144497177..c82c024235 100644 --- a/src/runtime/debug/garbage.go +++ b/src/runtime/debug/garbage.go @@ -71,7 +71,7 @@ func ReadGCStats(stats *GCStats) { // See the allocation at the top of the function. sorted := stats.Pause[n : n+n] copy(sorted, stats.Pause) - sort.Sort(byDuration(sorted)) + sort.Slice(sorted, func(i, j int) bool { return sorted[i] < sorted[j] }) nq := len(stats.PauseQuantiles) - 1 for i := 0; i < nq; i++ { stats.PauseQuantiles[i] = sorted[len(sorted)*i/nq] @@ -81,12 +81,6 @@ func ReadGCStats(stats *GCStats) { } } -type byDuration []time.Duration - -func (x byDuration) Len() int { return len(x) } -func (x byDuration) Swap(i, j int) { x[i], x[j] = x[j], x[i] } -func (x byDuration) Less(i, j int) bool { return x[i] < x[j] } - // SetGCPercent sets the garbage collection target percentage: // a collection is triggered when the ratio of freshly allocated data // to live data remaining after the previous collection reaches this percentage. -- cgit v1.3