YTSFlix_Go/vendor/github.com/anacrolix/torrent/bencode/misc.go

29 lines
473 B
Go
Raw Normal View History

2018-11-04 14:58:15 +00:00
package bencode
import (
"reflect"
"unsafe"
)
// Wow Go is retarded.
var marshalerType = reflect.TypeOf(func() *Marshaler {
var m Marshaler
return &m
}()).Elem()
// Wow Go is retarded.
var unmarshalerType = reflect.TypeOf(func() *Unmarshaler {
var i Unmarshaler
return &i
}()).Elem()
func bytesAsString(b []byte) string {
if len(b) == 0 {
return ""
}
return *(*string)(unsafe.Pointer(&reflect.StringHeader{
uintptr(unsafe.Pointer(&b[0])),
len(b),
}))
}