runtime: redundant allocation after type assertion #64541
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
Milestone
Go version
go version go1.21.4 linux/amd64
What operating system and processor architecture are you using (
go env
)?What did you do?
Consider example snippet and a benchmark:
What did you expect to see?
No difference in benchmarks for
setString
andsetString2
.What did you see instead?
setString
allocates to convert strings
intoany
argument ofsink
althoughs
is obtained fromany
v
.Perhaps compiler could figure out that
s
isv
and passv
tosink
instead.The text was updated successfully, but these errors were encountered: