]> Cypherpunks repositories - gostls13.git/commitdiff
internal/syscall/windows: simplify unsafe.Slice usage
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Fri, 9 Sep 2022 18:34:35 +0000 (01:34 +0700)
committerGopher Robot <gobot@golang.org>
Fri, 9 Sep 2022 20:29:05 +0000 (20:29 +0000)
CL 428780 used unsafe.Slice instead of unsafeheader for simplifiying the
code. However, it can be even simpler, since "p" is already a *uin16,
the unsafe cast is not necessary.

Change-Id: Idc492b73518637997e85c0b33f8591bd19b7929f
Reviewed-on: https://go-review.googlesource.com/c/go/+/429915
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/internal/syscall/windows/syscall_windows.go

index 39ff25fcb7bb1580b42a6891c1485f39f0329bd7..8ace2a27e79fcb5f84fa87b959469468050de263 100644 (file)
@@ -25,7 +25,7 @@ func UTF16PtrToString(p *uint16) string {
                n++
        }
        // Turn *uint16 into []uint16.
-       s := unsafe.Slice((*uint16)(unsafe.Pointer(p)), n)
+       s := unsafe.Slice(p, n)
        // Decode []uint16 into string.
        return string(utf16.Decode(s))
 }