• Josh Bleecher Snyder's avatar
    cmd/compile: avoid runtime call during switch string(byteslice) · 566e3e07
    Josh Bleecher Snyder authored
    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: 's avatarMatthew Dempsky <mdempsky@google.com>
    566e3e07
swt.go 26.7 KB