aboutsummaryrefslogtreecommitdiff
path: root/src/strings/builder.go
diff options
context:
space:
mode:
authorcuiweixie <cuiweixie@gmail.com>2022-09-03 14:35:41 +0800
committerGopher Robot <gobot@golang.org>2022-09-07 01:33:55 +0000
commit2ee075dc47ec686b48746fd261212b044705fcdc (patch)
treedafd7bee1731faec7444a22b5fabfedefdd4cc53 /src/strings/builder.go
parent92b8f4e293421b3b61e868d593a89315c788c327 (diff)
downloadgo-2ee075dc47ec686b48746fd261212b044705fcdc.tar.xz
strings: simplify code using unsafe.StringData
Updates #54854 Change-Id: I93396dc92bd2decba895f2d059e1aeffcd22312c Reviewed-on: https://go-review.googlesource.com/c/go/+/428158 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
Diffstat (limited to 'src/strings/builder.go')
-rw-r--r--src/strings/builder.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/strings/builder.go b/src/strings/builder.go
index 096e9c765e..7710464a0d 100644
--- a/src/strings/builder.go
+++ b/src/strings/builder.go
@@ -45,7 +45,7 @@ func (b *Builder) copyCheck() {
// String returns the accumulated string.
func (b *Builder) String() string {
- return *(*string)(unsafe.Pointer(&b.buf))
+ return unsafe.String(unsafe.SliceData(b.buf), len(b.buf))
}
// Len returns the number of accumulated bytes; b.Len() == len(b.String()).