diff options
| author | cuiweixie <cuiweixie@gmail.com> | 2022-09-03 14:20:20 +0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2022-09-07 01:33:52 +0000 |
| commit | 2a627afe139b9e7b079da14b30beeb0bb8f5d09e (patch) | |
| tree | e0d3d6217711c23e8d4d77dec3801b6651097064 /src/bytes | |
| parent | 502504f433fa03fc8400b23c3fd10d5eb6e2b620 (diff) | |
| download | go-2a627afe139b9e7b079da14b30beeb0bb8f5d09e.tar.xz | |
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>
Diffstat (limited to 'src/bytes')
| -rw-r--r-- | src/bytes/bytes_test.go | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/bytes/bytes_test.go b/src/bytes/bytes_test.go index 05c7ccc50a..7263af3ed0 100644 --- a/src/bytes/bytes_test.go +++ b/src/bytes/bytes_test.go @@ -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) } } |
