From fe69121bc538260cf91f11dab705335b690e51a3 Mon Sep 17 00:00:00 2001 From: Paschalis Tsilias Date: Wed, 13 Sep 2023 12:44:17 +0300 Subject: cmd/compile: optimize []byte(string1 + string2) This CL optimizes the compilation of string-to-bytes conversion in the case of string additions. Fixes #62407 Change-Id: Ic47df758478e5d061880620025c4ec7dbbff8a64 Reviewed-on: https://go-review.googlesource.com/c/go/+/527935 Reviewed-by: Cuong Manh Le Reviewed-by: Keith Randall Auto-Submit: Keith Randall LUCI-TryBot-Result: Go LUCI Reviewed-by: Keith Randall Reviewed-by: Tim King --- test/codegen/strings.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/codegen') diff --git a/test/codegen/strings.go b/test/codegen/strings.go index f98c062d1b..64dcf4c842 100644 --- a/test/codegen/strings.go +++ b/test/codegen/strings.go @@ -26,6 +26,11 @@ func ToByteSlice() []byte { // Issue #24698 return []byte("foo") } +func ConvertToByteSlice(a, b, c string) []byte { + // amd64:`.*runtime.concatbyte3` + return []byte(a + b + c) +} + // Loading from read-only symbols should get transformed into constants. func ConstantLoad() { // 12592 = 0x3130 -- cgit v1.3