-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
What version of Go are you using (go version)?
$ go version go version go1.17rc1 linux/amd64
Does this issue reproduce with the latest release?
Yes
What did you do?
package main
import "testing"
var str = "1234567890123456789012345678901234567890"
func f() {
_ = append([]byte(str), str...)
}
func main() {
stat := func( f func() ) int {
allocs := testing.AllocsPerRun(1, f)
return int(allocs)
}
println(stat(f)) // 2
}What did you expect to see?
One allocation.
What did you see instead?
Two instead.
The allocation for []byte(str) could be saved.
Partially related to #43429.
OneOfOne, Sandertv, beoran, YenForYang, bcmills and 6 more
Metadata
Metadata
Assignees
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.