Skip to content

Commit 2a627af

Browse files
cuiweixiegopherbot
authored andcommitted
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 <[email protected]> Reviewed-by: Bryan Mills <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]>
1 parent 502504f commit 2a627af

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/bytes/bytes_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,9 +2186,7 @@ func TestClone(t *testing.T) {
21862186
t.Errorf("Clone(%#v) return value should not be equal to nil slice.", input)
21872187
}
21882188

2189-
inputHeader := (*reflect.SliceHeader)(unsafe.Pointer(&input))
2190-
cloneHeader := (*reflect.SliceHeader)(unsafe.Pointer(&clone))
2191-
if cap(input) != 0 && cloneHeader.Data == inputHeader.Data {
2189+
if cap(input) != 0 && unsafe.SliceData(input) == unsafe.SliceData(clone) {
21922190
t.Errorf("Clone(%q) return value should not reference inputs backing memory.", input)
21932191
}
21942192
}

0 commit comments

Comments
 (0)