From: Marvin Stenger Date: Thu, 24 Sep 2015 14:01:50 +0000 (+0200) Subject: cmd/link/internal/ld: removed some uses of stringsCompare X-Git-Tag: go1.6beta1~986 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=550b7ccf77b0484aae10275ab7b9e7c510f8e7e1;p=gostls13.git cmd/link/internal/ld: removed some uses of stringsCompare Only one use of stringsCompare is left. Cannot simply be replaced by strings.Compare for bootstrapping reasons I guess. Moving the function away from util.go to the actual destination data.go also would not help much. So I left this one unchanged for readability and convenience. Change-Id: I60d22fec0be8f8c47c80586436f9a550af59194e Reviewed-on: https://go-review.googlesource.com/14953 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- diff --git a/src/cmd/link/internal/ld/macho.go b/src/cmd/link/internal/ld/macho.go index ccc84915c0..c02b83f3fc 100644 --- a/src/cmd/link/internal/ld/macho.go +++ b/src/cmd/link/internal/ld/macho.go @@ -625,10 +625,10 @@ func (x machoscmp) Less(i, j int) bool { k1 := symkind(s1) k2 := symkind(s2) if k1 != k2 { - return k1-k2 < 0 + return k1 < k2 } - return stringsCompare(s1.Extname, s2.Extname) < 0 + return s1.Extname < s2.Extname } func machogenasmsym(put func(*LSym, string, int, int64, int64, int, *LSym)) { diff --git a/src/cmd/link/internal/ld/pe.go b/src/cmd/link/internal/ld/pe.go index 4a7d710856..16ce7bd016 100644 --- a/src/cmd/link/internal/ld/pe.go +++ b/src/cmd/link/internal/ld/pe.go @@ -684,21 +684,11 @@ func addimports(datsect *IMAGE_SECTION_HEADER) { Cseek(endoff) } -type pescmp []*LSym +type byExtname []*LSym -func (x pescmp) Len() int { - return len(x) -} - -func (x pescmp) Swap(i, j int) { - x[i], x[j] = x[j], x[i] -} - -func (x pescmp) Less(i, j int) bool { - s1 := x[i] - s2 := x[j] - return stringsCompare(s1.Extname, s2.Extname) < 0 -} +func (s byExtname) Len() int { return len(s) } +func (s byExtname) Swap(i, j int) { s[i], s[j] = s[j], s[i] } +func (s byExtname) Less(i, j int) bool { return s[i].Extname < s[j].Extname } func initdynexport() { nexport = 0 @@ -715,7 +705,7 @@ func initdynexport() { nexport++ } - sort.Sort(pescmp(dexport[:nexport])) + sort.Sort(byExtname(dexport[:nexport])) } func addexports() {