cmd/compile: use mapaccess1_fast64 for small keys #66446
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
Go version
go1.22
Output of
go env
in your module/workspace:What did you do?
Compile the following program:
What did you see happen?
The compiler output:
What did you expect to see?
runtime.mapaccess1_fast64
being used on both since thekey
type is smaller than a uint64.That said, there is some complications. For example, through
unsafe
, someone could writes values to the padding in-between thebool
field and theuint32
. Also, someone usingunsafe
could write a bit pattern to the bool that isn't 0 or 1.It isn't clear to me that this is something that someone can rely on.
However, even if we make the
key
struct exactly 64-bits wide with no padding and no bools, it still doesn't useruntime.mapaccess1_fast64
.The text was updated successfully, but these errors were encountered: