diff options
author | Daniel Martí <mvdan@mvdan.cc> | 2017-09-12 17:09:46 +0200 |
---|---|---|
committer | Daniel Martí <mvdan@mvdan.cc> | 2017-09-22 12:39:14 +0000 |
commit | 57e7d62455ae85a9d9471353286a7c640ecd0bc3 (patch) | |
tree | 8d54af6482ae985b6e5925567e64f07bd594f197 /src/unicode | |
parent | 67a0c783123556506d2a41ac6b512b00f855ea39 (diff) | |
download | go-57e7d62455ae85a9d9471353286a7c640ecd0bc3.tar.gz go-57e7d62455ae85a9d9471353286a7c640ecd0bc3.zip |
all: use sort.Slice in a few more places
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í <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/unicode')
-rw-r--r-- | src/unicode/maketables.go | 10 |
1 files changed, 3 insertions, 7 deletions
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 |