[dev.regabi] cmd/compile: change NodeSet to NameSet

The only user of NodeSet (computing initialization dependencies) only
needs to store *Names in this structure. So change its definition to
match that need, and update the code in initorder.go accordingly.

Passes buildall w/ toolstash -cmp.

Updates #42982.

Change-Id: I181a8aaf9bc71e88f4ac009c4f381a718080e48f
Reviewed-on: https://go-review.googlesource.com/c/go/+/275752
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Matthew Dempsky 2020-12-05 15:49:03 -08:00
parent 46b6e70e3b
commit 6c5967e528
2 changed files with 18 additions and 18 deletions

View file

@ -585,26 +585,26 @@ func (q *NodeQueue) PopLeft() Node {
return n
}
// NodeSet is a set of Nodes.
type NodeSet map[Node]struct{}
// NameSet is a set of Names.
type NameSet map[*Name]struct{}
// Has reports whether s contains n.
func (s NodeSet) Has(n Node) bool {
func (s NameSet) Has(n *Name) bool {
_, isPresent := s[n]
return isPresent
}
// Add adds n to s.
func (s *NodeSet) Add(n Node) {
func (s *NameSet) Add(n *Name) {
if *s == nil {
*s = make(map[Node]struct{})
*s = make(map[*Name]struct{})
}
(*s)[n] = struct{}{}
}
// Sorted returns s sorted according to less.
func (s NodeSet) Sorted(less func(Node, Node) bool) []Node {
var res []Node
func (s NameSet) Sorted(less func(*Name, *Name) bool) []*Name {
var res []*Name
for n := range s {
res = append(res, n)
}