aboutsummaryrefslogtreecommitdiff
path: root/src/strings
diff options
context:
space:
mode:
authorqiulaidongfeng <2645477756@qq.com>2024-05-04 00:40:18 +0000
committerGopher Robot <gobot@golang.org>2024-05-04 01:23:42 +0000
commitae6af9b3d8c88c29c81230abbe697cf61e2ae594 (patch)
treefc80836350caa982386d533fb26e25217b7a0188 /src/strings
parent7994da4cc143fa16803bf80188b849457b7d55c3 (diff)
downloadgo-ae6af9b3d8c88c29c81230abbe697cf61e2ae594.tar.xz
strings: move Clone to stringslite
Follow-up CL help package like unique use Clone. Change-Id: Ie64adf7e1a331f47c3cfe178c368d72fc72493ff GitHub-Last-Rev: 499476cc4acdf58ecf0fec9f7281bfb90edc7c82 GitHub-Pull-Request: golang/go#67106 Reviewed-on: https://go-review.googlesource.com/c/go/+/581956 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/strings')
-rw-r--r--src/strings/clone.go9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/strings/clone.go b/src/strings/clone.go
index d14df11d49..f965b5963a 100644
--- a/src/strings/clone.go
+++ b/src/strings/clone.go
@@ -5,7 +5,7 @@
package strings
import (
- "unsafe"
+ "internal/stringslite"
)
// Clone returns a fresh copy of s.
@@ -19,10 +19,5 @@ import (
// For strings of length zero the string "" will be returned
// and no allocation is made.
func Clone(s string) string {
- if len(s) == 0 {
- return ""
- }
- b := make([]byte, len(s))
- copy(b, s)
- return unsafe.String(&b[0], len(b))
+ return stringslite.Clone(s)
}