mirror of
https://github.com/rwinkhart/sys.git
synced 2026-08-28 04:46:44 -04:00
all: simplify unsafe.Slice usage in {Byte,UTF16}PtrToString
On windows, use unsafe.Slice instead of unsafeheader as already the case for unix and plan9. The pointers are already *byte/*uint16, so the type conversion can be omitted as well. Change-Id: Ida7264cc0c1948bf563ed91d51e637edcdafb77a Reviewed-on: https://go-review.googlesource.com/c/sys/+/430515 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
This commit is contained in:
committed by
Tobias Klauser
parent
3275c407ce
commit
76c7481b51
+1
-2
@@ -80,8 +80,7 @@ func BytePtrToString(p *byte) string {
|
||||
ptr = unsafe.Pointer(uintptr(ptr) + 1)
|
||||
}
|
||||
|
||||
s := unsafe.Slice((*byte)(unsafe.Pointer(p)), n)
|
||||
return string(s)
|
||||
return string(unsafe.Slice(p, n))
|
||||
}
|
||||
|
||||
// Single-word zero for use when we need a valid pointer to 0 bytes.
|
||||
|
||||
Reference in New Issue
Block a user