]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: sort interface methods in tointerface0
authorMatthew Dempsky <mdempsky@google.com>
Fri, 11 Mar 2016 07:59:59 +0000 (23:59 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Fri, 11 Mar 2016 18:25:42 +0000 (18:25 +0000)
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>
src/cmd/compile/internal/gc/dcl.go
src/cmd/compile/internal/gc/subr.go

index e1209ff8ecb3de6f24989e2a8aee948029773510..528771627cf957ac6333e1592807cc61c81b5c7b 100644 (file)
@@ -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
index 9a7e6b68c2b603865942e195fdaff61334c0e222..ff4d4409ea7c4a68f500d994317bae792b3fe428 100644 (file)
@@ -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