1
0
mirror of https://github.com/golang/go synced 2024-11-18 08:54:45 -07:00

internal/syscall/windows: simplify unsafe.Slice usage

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>
This commit is contained in:
Cuong Manh Le 2022-09-10 01:34:35 +07:00 committed by Gopher Robot
parent 59ba97bf3b
commit 54182ff54a

View 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))
}