]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link/internal/ld: removed some uses of stringsCompare
authorMarvin Stenger <marvin.stenger94@gmail.com>
Thu, 24 Sep 2015 14:01:50 +0000 (16:01 +0200)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 24 Sep 2015 15:05:04 +0000 (15:05 +0000)
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 <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/link/internal/ld/macho.go
src/cmd/link/internal/ld/pe.go

index ccc84915c0eaa8e30d3e790ef3844f0a21f8e57a..c02b83f3fc7c67ef0d22a1ad85d245342c73e7fc 100644 (file)
@@ -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)) {
index 4a7d7108561224d91de0e703a23da289422ccad6..16ce7bd016b65438937a464971fa2cc102d2bc19 100644 (file)
@@ -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() {