1
0
mirror of https://github.com/golang/go synced 2024-11-05 17:36:15 -07:00

cmd/compile/internal/gc: various cleanups

Remove a couple of unnecessary var declarations, an unused sort.Sort
type, and simplify a range by using the two-name variant.

Change-Id: Ia251f634db0bfbe8b1d553b8659272ddbd13b2c3
Reviewed-on: https://go-review.googlesource.com/102336
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Daniel Martí 2018-03-23 20:20:50 +00:00
parent bf8eef2adc
commit b1892d740e
4 changed files with 7 additions and 17 deletions

View File

@ -465,8 +465,8 @@ func createComplexVars(fn *Func) ([]*Node, []*dwarf.Var, map[*Node]bool) {
var vars []*dwarf.Var var vars []*dwarf.Var
ssaVars := make(map[*Node]bool) ssaVars := make(map[*Node]bool)
for varID := range debugInfo.Vars { for varID, dvar := range debugInfo.Vars {
n := debugInfo.Vars[varID].(*Node) n := dvar.(*Node)
ssaVars[n] = true ssaVars[n] = true
for _, slot := range debugInfo.VarSlots[varID] { for _, slot := range debugInfo.VarSlots[varID] {
ssaVars[debugInfo.Slots[slot].N.(*Node)] = true ssaVars[debugInfo.Slots[slot].N.(*Node)] = true

View File

@ -304,17 +304,16 @@ func affectedNode(v *ssa.Value) (*Node, ssa.SymEffect) {
return nil, 0 return nil, 0
} }
var n *Node
switch a := v.Aux.(type) { switch a := v.Aux.(type) {
case nil, *obj.LSym: case nil, *obj.LSym:
// ok, but no node // ok, but no node
return nil, e
case *Node: case *Node:
n = a return a, e
default: default:
Fatalf("weird aux: %s", v.LongString()) Fatalf("weird aux: %s", v.LongString())
return nil, e
} }
return n, e
} }
// Constructs a new liveness structure used to hold the global state of the // Constructs a new liveness structure used to hold the global state of the

View File

@ -343,9 +343,8 @@ func methodfunc(f *types.Type, receiver *types.Type) *types.Type {
in = append(in, d) in = append(in, d)
} }
var d *Node
for _, t := range f.Params().Fields().Slice() { for _, t := range f.Params().Fields().Slice() {
d = nod(ODCLFIELD, nil, nil) d := nod(ODCLFIELD, nil, nil)
d.Type = t.Type d.Type = t.Type
d.SetIsddd(t.Isddd()) d.SetIsddd(t.Isddd())
in = append(in, d) in = append(in, d)
@ -353,7 +352,7 @@ func methodfunc(f *types.Type, receiver *types.Type) *types.Type {
var out []*Node var out []*Node
for _, t := range f.Results().Fields().Slice() { for _, t := range f.Results().Fields().Slice() {
d = nod(ODCLFIELD, nil, nil) d := nod(ODCLFIELD, nil, nil)
d.Type = t.Type d.Type = t.Type
out = append(out, d) out = append(out, d)
} }

View File

@ -113,14 +113,6 @@ func compactScopes(dwarfScopes []dwarf.Scope) []dwarf.Scope {
return dwarfScopes return dwarfScopes
} }
type pcsByPC []scopedPCs
func (s pcsByPC) Len() int { return len(s) }
func (s pcsByPC) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s pcsByPC) Less(i, j int) bool {
return s[i].start < s[j].start
}
type varsByScopeAndOffset struct { type varsByScopeAndOffset struct {
vars []*dwarf.Var vars []*dwarf.Var
scopes []ScopeID scopes []ScopeID