mirror of
https://github.com/golang/go
synced 2024-11-19 16:14:49 -07:00
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 <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
53984e5be2
commit
d9bb693960
@ -7,6 +7,7 @@ package gc
|
|||||||
import (
|
import (
|
||||||
"cmd/internal/obj"
|
"cmd/internal/obj"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -975,6 +976,7 @@ func tointerface0(t *Type, l []*Node) *Type {
|
|||||||
fields = append(fields, f)
|
fields = append(fields, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sort.Sort(methcmp(fields))
|
||||||
t.SetFields(fields)
|
t.SetFields(fields)
|
||||||
|
|
||||||
for f, it := IterFields(t); f != nil && !t.Broke; f = it.Next() {
|
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)
|
checkdupfields("method", t)
|
||||||
t = sortinter(t)
|
|
||||||
checkwidth(t)
|
checkwidth(t)
|
||||||
|
|
||||||
return t
|
return t
|
||||||
|
@ -416,13 +416,6 @@ func (x methcmp) Less(i, j int) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func sortinter(t *Type) *Type {
|
|
||||||
s := t.FieldSlice()
|
|
||||||
sort.Sort(methcmp(s))
|
|
||||||
t.SetFields(s)
|
|
||||||
return t
|
|
||||||
}
|
|
||||||
|
|
||||||
func Nodintconst(v int64) *Node {
|
func Nodintconst(v int64) *Node {
|
||||||
c := Nod(OLITERAL, nil, nil)
|
c := Nod(OLITERAL, nil, nil)
|
||||||
c.Addable = true
|
c.Addable = true
|
||||||
|
Loading…
Reference in New Issue
Block a user