Skip to content

Commit ba1ef54

Browse files
cuiweixiegopherbot
authored andcommitted
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 <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 4fe4601 commit ba1ef54

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/syscall/syscall_darwin.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,7 @@ func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
310310
break
311311
}
312312
// Copy entry into return buffer.
313-
s := struct {
314-
ptr unsafe.Pointer
315-
siz int
316-
cap int
317-
}{ptr: unsafe.Pointer(&entry), siz: reclen, cap: reclen}
318-
copy(buf, *(*[]byte)(unsafe.Pointer(&s)))
313+
copy(buf, unsafe.Slice((*byte)(unsafe.Pointer(&entry)), reclen))
319314
buf = buf[reclen:]
320315
n += reclen
321316
cnt++

0 commit comments

Comments
 (0)