]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: include all entries in map literal hint size
authorKeith Randall <khr@golang.org>
Sun, 6 Feb 2022 17:43:39 +0000 (09:43 -0800)
committerKeith Randall <khr@golang.org>
Tue, 1 Mar 2022 23:20:30 +0000 (23:20 +0000)
commitaaa3d39f270d7b9957f34f3d2a68decba63beffe
tree8428a291d565262b94f73b424f8956353d910651
parentd40e7bb1744507be421b80c19372b9411c9856b4
cmd/compile: include all entries in map literal hint size

Currently we only include static entries in the hint for sizing
the map when allocating a map for a map literal. Change that to
include all entries.

This will be an overallocation if the dynamic entries in the map have
equal keys, but equal keys in map literals are rare, and at worst we
waste a bit of space.

Fixes #43020

Change-Id: I232f82f15316bdf4ea6d657d25a0b094b77884ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/383634
Run-TryBot: Keith Randall <khr@golang.org>
Trust: Keith Randall <khr@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/compile/internal/ir/expr.go
src/cmd/compile/internal/walk/complit.go
src/cmd/compile/internal/walk/order.go
test/codegen/maps.go