]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: avoid runtime call during switch string(byteslice)
authorJosh Bleecher Snyder <josharian@gmail.com>
Thu, 19 Apr 2018 01:28:34 +0000 (18:28 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Sat, 21 Apr 2018 00:50:50 +0000 (00:50 +0000)
commit566e3e074c089568412a44a8d315c2881cfd8e8f
treef977d94bb790728d40e08f1a9b3c68b3e1039111
parentf6ca6eddaa0ce78093094b3485aa21669c6c76b4
cmd/compile: avoid runtime call during switch string(byteslice)

This triggers three times while building std,
once in image/png and twice in go/internal/gccgoimporter.

There are no instances in std in which a more aggressive
optimization would have triggered.

This doesn't necessarily avoid an allocation,
because escape analysis is already able in many cases
to use a temporary backing for the string,
but it does at a minimum avoid the runtime call and copy.

Fixes #24937

Change-Id: I7019e85638ba8cd7e2f03890e672558b858579bc
Reviewed-on: https://go-review.googlesource.com/108035
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/swt.go
test/fixedbugs/issue24937.go [new file with mode: 0644]