1
0
mirror of https://github.com/golang/go synced 2024-11-17 08:24:43 -07:00

cmd/internal/goobj: use unsafe.String in toString func

This commit is contained in:
Jes Cok 2023-07-01 21:41:51 +08:00
parent 5b72f45dd1
commit f0aa251dbb

View File

@ -662,13 +662,7 @@ func toString(b []byte) string {
if len(b) == 0 {
return ""
}
var s string
hdr := (*unsafeheader.String)(unsafe.Pointer(&s))
hdr.Data = unsafe.Pointer(&b[0])
hdr.Len = len(b)
return s
return unsafe.String(&b[0], len(b))
}
func (r *Reader) StringRef(off uint32) string {