From 57e7d62455ae85a9d9471353286a7c640ecd0bc3 Mon Sep 17 00:00:00 2001 From: Daniel Martí Date: Tue, 12 Sep 2017 17:09:46 +0200 Subject: all: use sort.Slice in a few more places MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do the low-hanging fruit - tiny Less functions that are used exactly once. This reduces the amount of code and puts the logic in a single place. Change-Id: I9d4544cd68de5a95e55019bdad1fca0a1dbfae9c Reviewed-on: https://go-review.googlesource.com/63171 Run-TryBot: Daniel Martí TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/unicode/maketables.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/unicode') diff --git a/src/unicode/maketables.go b/src/unicode/maketables.go index 3fcf8af6bf..9a92a0130a 100644 --- a/src/unicode/maketables.go +++ b/src/unicode/maketables.go @@ -1132,12 +1132,6 @@ func printLatinProperties() { printf("}\n\n") } -type runeSlice []rune - -func (p runeSlice) Len() int { return len(p) } -func (p runeSlice) Less(i, j int) bool { return p[i] < p[j] } -func (p runeSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } - func printCasefold() { // Build list of case-folding groups attached to each canonical folded char (typically lower case). var caseOrbit = make([][]rune, MaxChar+1) @@ -1184,7 +1178,9 @@ func printCasefold() { if orb == nil { continue } - sort.Sort(runeSlice(orb)) + sort.Slice(orb, func(i, j int) bool { + return orb[i] < orb[j] + }) c := orb[len(orb)-1] for _, d := range orb { chars[c].caseOrbit = d -- cgit v1.3