mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
92b8f4e293
commit
2ee075dc47
5 changed files with 7 additions and 12 deletions
|
|
@ -660,8 +660,7 @@ func TestMap(t *testing.T) {
|
|||
}
|
||||
orig := "Input string that we expect not to be copied."
|
||||
m = Map(identity, orig)
|
||||
if (*reflect.StringHeader)(unsafe.Pointer(&orig)).Data !=
|
||||
(*reflect.StringHeader)(unsafe.Pointer(&m)).Data {
|
||||
if unsafe.StringData(orig) != unsafe.StringData(m) {
|
||||
t.Error("unexpected copy during identity map")
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue