mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: add size hint to map literal allocations
Might as well tell the runtime how large the map is going to be. This avoids grow work and allocations while the map is being built. Will wait for 1.8. Fixes #15880 Fixes #16279 Change-Id: I377e3e5ec1e2e76ea2a50cc00810adda20ad0e79 Reviewed-on: https://go-review.googlesource.com/23558 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
parent
35e25ef62e
commit
1faea596e4
2 changed files with 6 additions and 1 deletions
|
|
@ -545,6 +545,11 @@ func (n *Nodes) Set1(node *Node) {
|
|||
n.slice = &[]*Node{node}
|
||||
}
|
||||
|
||||
// Set2 sets n to a slice containing two nodes.
|
||||
func (n *Nodes) Set2(n1, n2 *Node) {
|
||||
n.slice = &[]*Node{n1, n2}
|
||||
}
|
||||
|
||||
// MoveNodes sets n to the contents of n2, then clears n2.
|
||||
func (n *Nodes) MoveNodes(n2 *Nodes) {
|
||||
n.slice = n2.slice
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue