mirror of
https://github.com/golang/go
synced 2024-11-26 16:16:57 -07:00
cmd/compile: use typeAndStr directly in signatslice
Currently, we store *types.Type in signatslice, then convert it to typeAndStr during write runtime type process. Instead, we can just store typeAndStr directly in signatslice when adding type to signatset. Not a big win, but simplify the code a bit. Change-Id: Ie1c8cfa5141da32b6ec3ce5844ba150d2765fe90 Reviewed-on: https://go-review.googlesource.com/c/go/+/343529 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
e9e0d1ef70
commit
303446395d
@ -44,7 +44,7 @@ var (
|
|||||||
// Tracking which types need runtime type descriptor
|
// Tracking which types need runtime type descriptor
|
||||||
signatset = make(map[*types.Type]struct{})
|
signatset = make(map[*types.Type]struct{})
|
||||||
// Queue of types wait to be generated runtime type descriptor
|
// Queue of types wait to be generated runtime type descriptor
|
||||||
signatslice []*types.Type
|
signatslice []typeAndStr
|
||||||
|
|
||||||
gcsymmu sync.Mutex // protects gcsymset and gcsymslice
|
gcsymmu sync.Mutex // protects gcsymset and gcsymslice
|
||||||
gcsymset = make(map[*types.Type]struct{})
|
gcsymset = make(map[*types.Type]struct{})
|
||||||
@ -1238,21 +1238,16 @@ func NeedRuntimeType(t *types.Type) {
|
|||||||
}
|
}
|
||||||
if _, ok := signatset[t]; !ok {
|
if _, ok := signatset[t]; !ok {
|
||||||
signatset[t] = struct{}{}
|
signatset[t] = struct{}{}
|
||||||
signatslice = append(signatslice, t)
|
signatslice = append(signatslice, typeAndStr{t: t, short: types.TypeSymName(t), regular: t.String()})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WriteRuntimeTypes() {
|
func WriteRuntimeTypes() {
|
||||||
// Process signatset. Use a loop, as writeType adds
|
// Process signatslice. Use a loop, as writeType adds
|
||||||
// entries to signatset while it is being processed.
|
// entries to signatslice while it is being processed.
|
||||||
signats := make([]typeAndStr, len(signatslice))
|
|
||||||
for len(signatslice) > 0 {
|
for len(signatslice) > 0 {
|
||||||
signats = signats[:0]
|
signats := signatslice
|
||||||
// Transfer entries to a slice and sort, for reproducible builds.
|
// Sort for reproducible builds.
|
||||||
for _, t := range signatslice {
|
|
||||||
signats = append(signats, typeAndStr{t: t, short: types.TypeSymName(t), regular: t.String()})
|
|
||||||
}
|
|
||||||
signatslice = signatslice[:0]
|
|
||||||
sort.Sort(typesByString(signats))
|
sort.Sort(typesByString(signats))
|
||||||
for _, ts := range signats {
|
for _, ts := range signats {
|
||||||
t := ts.t
|
t := ts.t
|
||||||
@ -1261,6 +1256,7 @@ func WriteRuntimeTypes() {
|
|||||||
writeType(types.NewPtr(t))
|
writeType(types.NewPtr(t))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
signatslice = signatslice[len(signats):]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit GC data symbols.
|
// Emit GC data symbols.
|
||||||
|
Loading…
Reference in New Issue
Block a user