Files
fumitok/helper.go
源文雨 62c237674f init
2024-10-13 19:43:12 +09:00

16 lines
304 B
Go

package fumitok
import (
"unsafe"
)
// BytesToString 没有内存开销的转换
func BytesToString(b []byte) string {
return *(*string)(unsafe.Pointer(&b))
}
// StringToBytes 没有内存开销的转换
func StringToBytes(s string) (b []byte) {
return unsafe.Slice(unsafe.StringData(s), len(s))
}