Closed
Description
- What version of Go are you using (
go version
)?
go version go1.7beta2 linux/amd64 - What operating system and processor architecture are you using (
go env
)?
GOHOSTARCH="amd64"
GOHOSTOS="linux"
Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
Given the following example: https://play.golang.org/p/a_ow6e7II7
I would expect the compiler to transform the calls to strings.Join
with a finite number of elements into simple string concatenations. The reason is that these calls might be used on hot-paths for code, for example: aws/aws-sdk-go#729
The results might be small, see below for my machine, but any speed improvement is a good one imho
go test -bench=.
BenchmarkStringsJoin-8 10000000 140 ns/op
BenchmarkStringsConcat-8 20000000 92.6 ns/op
PASS
ok some/package 3.505s
go test -bench=. -benchmem
BenchmarkStringsJoin-8 10000000 136 ns/op 128 B/op 2 allocs/op
BenchmarkStringsConcat-8 20000000 96.6 ns/op 64 B/op 1 allocs/op
PASS
ok some/package 3.565s
Thank you.