diff --git a/bencode/misc.go b/bencode/misc.go index 3b95afcecc..38b7fce84f 100644 --- a/bencode/misc.go +++ b/bencode/misc.go @@ -18,13 +18,5 @@ var unmarshalerType = reflect.TypeOf(func() *Unmarshaler { }()).Elem() func bytesAsString(b []byte) string { - if len(b) == 0 { - return "" - } - // See https://github.com/golang/go/issues/40701. - var s string - hdr := (*reflect.StringHeader)(unsafe.Pointer(&s)) - hdr.Data = uintptr(unsafe.Pointer(&b[0])) - hdr.Len = len(b) - return s + return *(*string)(unsafe.Pointer(&b)) }