diff options
| author | Cuong Manh Le <cuong.manhle.vn@gmail.com> | 2023-05-23 11:23:48 +0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-05-23 19:27:38 +0000 |
| commit | 35a71dc56dfd0426cb3e72f8803cf58160c602ec (patch) | |
| tree | 086b062c0cd6c6dde3e43dfa1fc4bfe10733dd70 /test/codegen/strings.go | |
| parent | 3651d8e516950c46035cdc04ec3db1146f0590d2 (diff) | |
| download | go-35a71dc56dfd0426cb3e72f8803cf58160c602ec.tar.xz | |
cmd/compile: avoid slicebytetostring call in len(string([]byte))
Change-Id: Ie04503e61400a793a6a29a4b58795254deabe472
Reviewed-on: https://go-review.googlesource.com/c/go/+/497276
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'test/codegen/strings.go')
| -rw-r--r-- | test/codegen/strings.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/test/codegen/strings.go b/test/codegen/strings.go index a2c2fc0a62..94512f5cd3 100644 --- a/test/codegen/strings.go +++ b/test/codegen/strings.go @@ -14,6 +14,11 @@ func CountRunes(s string) int { // Issue #24923 return len([]rune(s)) } +func CountBytes(s []byte) int { + // amd64:-`.*runtime.slicebytetostring` + return len(string(s)) +} + func ToByteSlice() []byte { // Issue #24698 // amd64:`LEAQ\ttype:\[3\]uint8` // amd64:`CALL\truntime\.newobject` |
