From: Matthew Dempsky Date: Fri, 11 Mar 2016 07:59:59 +0000 (-0800) Subject: cmd/compile: sort interface methods in tointerface0 X-Git-Tag: go1.7beta1~1391 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d9bb69396034d6e3553018592926fbf0cd75a0cf;p=gostls13.git cmd/compile: sort interface methods in tointerface0 Might as well sort them while they're still in a slice. Change-Id: I40c25ddc5c054dcb4da2aeefa79947967609d599 Reviewed-on: https://go-review.googlesource.com/20591 Run-TryBot: Matthew Dempsky TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- diff --git a/src/cmd/compile/internal/gc/dcl.go b/src/cmd/compile/internal/gc/dcl.go index e1209ff8ec..528771627c 100644 --- a/src/cmd/compile/internal/gc/dcl.go +++ b/src/cmd/compile/internal/gc/dcl.go @@ -7,6 +7,7 @@ package gc import ( "cmd/internal/obj" "fmt" + "sort" "strings" ) @@ -975,6 +976,7 @@ func tointerface0(t *Type, l []*Node) *Type { fields = append(fields, f) } } + sort.Sort(methcmp(fields)) t.SetFields(fields) for f, it := IterFields(t); f != nil && !t.Broke; f = it.Next() { @@ -984,7 +986,6 @@ func tointerface0(t *Type, l []*Node) *Type { } checkdupfields("method", t) - t = sortinter(t) checkwidth(t) return t diff --git a/src/cmd/compile/internal/gc/subr.go b/src/cmd/compile/internal/gc/subr.go index 9a7e6b68c2..ff4d4409ea 100644 --- a/src/cmd/compile/internal/gc/subr.go +++ b/src/cmd/compile/internal/gc/subr.go @@ -416,13 +416,6 @@ func (x methcmp) Less(i, j int) bool { return false } -func sortinter(t *Type) *Type { - s := t.FieldSlice() - sort.Sort(methcmp(s)) - t.SetFields(s) - return t -} - func Nodintconst(v int64) *Node { c := Nod(OLITERAL, nil, nil) c.Addable = true