mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: add Type.SetNumElem
This removes all access to Type.Bound from outside type.go. Update sinit to make a new type rather than copy and mutate. Update bimport to create a new slice type instead of mutating TDDDFIELD. These are rare, so the extra allocs are nominal. I’m not happy about having a setter, but it appears the most practical route forward at the moment, and it only has a few uses. Passes toolstash -cmp. Change-Id: I174f07c8f336afc656904bde4bdbde4f3ef0db96 Reviewed-on: https://go-review.googlesource.com/21423 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
e504055e78
commit
5dd129bcff
4 changed files with 18 additions and 14 deletions
|
|
@ -688,12 +688,8 @@ func arraylit(ctxt int, pass int, n *Node, var_ *Node, init *Nodes) {
|
|||
}
|
||||
|
||||
func slicelit(ctxt int, n *Node, var_ *Node, init *Nodes) {
|
||||
// make an array type
|
||||
t := n.Type.Copy()
|
||||
t.Bound = n.Right.Int()
|
||||
t.Width = 0
|
||||
t.Sym = nil
|
||||
t.Haspointers = 0
|
||||
// make an array type corresponding the number of elements we have
|
||||
t := typArray(n.Type.Elem(), n.Right.Int())
|
||||
dowidth(t)
|
||||
|
||||
if ctxt != 0 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue