bytes: simplify code using unsafe.SliceData

Updates #54854

Change-Id: I9c14f9fa595f73eae44eb714abc5d486915893c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/428155
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
This commit is contained in:
cuiweixie 2022-09-03 14:20:20 +08:00 committed by Gopher Robot
parent 502504f433
commit 2a627afe13

View File

@ -2186,9 +2186,7 @@ func TestClone(t *testing.T) {
t.Errorf("Clone(%#v) return value should not be equal to nil slice.", input)
}
inputHeader := (*reflect.SliceHeader)(unsafe.Pointer(&input))
cloneHeader := (*reflect.SliceHeader)(unsafe.Pointer(&clone))
if cap(input) != 0 && cloneHeader.Data == inputHeader.Data {
if cap(input) != 0 && unsafe.SliceData(input) == unsafe.SliceData(clone) {
t.Errorf("Clone(%q) return value should not reference inputs backing memory.", input)
}
}