]> Cypherpunks repositories - gostls13.git/commit
cmd/compile, runtime: optimize concatbytes
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Tue, 25 Feb 2025 16:59:14 +0000 (23:59 +0700)
committerGopher Robot <gobot@golang.org>
Tue, 25 Feb 2025 20:23:56 +0000 (12:23 -0800)
commit8203265d5eef37bf41d7d2df126f77ebd5abc999
tree338cd9d6399cadfa660468fddf4a943bee81f4bb
parentbeb314c0dbcbe03b576123e99e1331348f858ecc
cmd/compile, runtime: optimize concatbytes

CL 527935 optimized []byte(string1 + string2) to use runtime.concatbytes
to prevent concatenating of strings before converting to slices.
However, the optimization is implemented without allowing temporary
buffer for slice on stack, causing un-necessary allocations.

To fix this, optimize concatbytes to use temporary buffer if the result
string length fit to the buffer size.

Fixes #71943

Change-Id: I1d3c374cd46aad8f83a271b8a5ca79094f9fd8db
Reviewed-on: https://go-review.googlesource.com/c/go/+/652395
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/cmd/compile/internal/test/issue71943_test.go [new file with mode: 0644]
src/cmd/compile/internal/typecheck/_builtin/runtime.go
src/cmd/compile/internal/typecheck/builtin.go
src/cmd/compile/internal/walk/convert.go
src/cmd/compile/internal/walk/expr.go
src/runtime/string.go