diff options
| author | cuiweixie <cuiweixie@gmail.com> | 2022-09-03 18:18:30 +0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2022-09-07 01:48:31 +0000 |
| commit | ba1ef54c1ee0e5ed8fd572dbb4ec67548cd5a55e (patch) | |
| tree | b1d4672debba72be60472af0eaef1e57b561e4e7 /src | |
| parent | 4fe4601d37179facbf7e79627ef9d6a236364505 (diff) | |
| download | go-ba1ef54c1ee0e5ed8fd572dbb4ec67548cd5a55e.tar.xz | |
syscall: simplify code using unsafe.Slice
Updates #54854
Change-Id: Ibaf4eea14a6259cdbca79e9e95db1602966f18e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/428176
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/syscall/syscall_darwin.go | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/src/syscall/syscall_darwin.go b/src/syscall/syscall_darwin.go index 663bd98c10..663ac4e94c 100644 --- a/src/syscall/syscall_darwin.go +++ b/src/syscall/syscall_darwin.go @@ -310,12 +310,7 @@ func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { break } // Copy entry into return buffer. - s := struct { - ptr unsafe.Pointer - siz int - cap int - }{ptr: unsafe.Pointer(&entry), siz: reclen, cap: reclen} - copy(buf, *(*[]byte)(unsafe.Pointer(&s))) + copy(buf, unsafe.Slice((*byte)(unsafe.Pointer(&entry)), reclen)) buf = buf[reclen:] n += reclen cnt++ |
