mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile,runtime: pass elem type to {make,grow}slice
No point in passing the slice type to these functions. All they need is the element type. One less indirection, maybe a few less []T type descriptors in the binary. Change-Id: Ib0b83b5f14ca21d995ecc199ce8ac00c4eb375e6 Reviewed-on: https://go-review.googlesource.com/22275 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
parent
0150f15a92
commit
bfe0cbdc50
4 changed files with 13 additions and 15 deletions
|
|
@ -1420,11 +1420,11 @@ opswitch:
|
|||
r = walkexpr(r, init)
|
||||
n = r
|
||||
} else {
|
||||
// makeslice(t *Type, nel int64, max int64) (ary []any)
|
||||
// makeslice(et *Type, nel int64, max int64) (ary []any)
|
||||
fn := syslook("makeslice")
|
||||
|
||||
fn = substArgTypes(fn, t.Elem()) // any-1
|
||||
n = mkcall1(fn, n.Type, init, typename(n.Type), conv(l, Types[TINT64]), conv(r, Types[TINT64]))
|
||||
n = mkcall1(fn, n.Type, init, typename(t.Elem()), conv(l, Types[TINT64]), conv(r, Types[TINT64]))
|
||||
}
|
||||
|
||||
case ORUNESTR:
|
||||
|
|
@ -2799,7 +2799,7 @@ func appendslice(n *Node, init *Nodes) *Node {
|
|||
fn = substArgTypes(fn, s.Type.Elem(), s.Type.Elem())
|
||||
|
||||
// s = growslice(T, s, n)
|
||||
nif.Nbody.Set1(Nod(OAS, s, mkcall1(fn, s.Type, &nif.Ninit, typename(s.Type), s, nn)))
|
||||
nif.Nbody.Set1(Nod(OAS, s, mkcall1(fn, s.Type, &nif.Ninit, typename(s.Type.Elem()), s, nn)))
|
||||
l = append(l, nif)
|
||||
|
||||
// s = s[:n]
|
||||
|
|
@ -2929,7 +2929,7 @@ func walkappend(n *Node, init *Nodes, dst *Node) *Node {
|
|||
fn = substArgTypes(fn, ns.Type.Elem(), ns.Type.Elem())
|
||||
|
||||
nx.Nbody.Set1(Nod(OAS, ns,
|
||||
mkcall1(fn, ns.Type, &nx.Ninit, typename(ns.Type), ns,
|
||||
mkcall1(fn, ns.Type, &nx.Ninit, typename(ns.Type.Elem()), ns,
|
||||
Nod(OADD, Nod(OLEN, ns, nil), na))))
|
||||
|
||||
l = append(l, nx)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue