diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2016-10-04 03:01:09 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2016-10-04 05:10:56 +0000 |
| commit | ad26bb5e3098cbfd7c0ad9a1dc9d38c92e50f06e (patch) | |
| tree | b84cfdbe334ab18e89b3c1099814f852f42b476b /src/runtime/debug | |
| parent | 2f184c65a5bdd422f88d841bb3a37fa60b3e1d52 (diff) | |
| download | go-ad26bb5e3098cbfd7c0ad9a1dc9d38c92e50f06e.tar.xz | |
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 <gobot@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
Diffstat (limited to 'src/runtime/debug')
| -rw-r--r-- | src/runtime/debug/garbage.go | 8 |
1 files changed, 1 insertions, 7 deletions
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. |
