✏️ str byte 转换改用 zb 的工具

This commit is contained in:
fumiama
2021-10-14 19:51:24 +08:00
parent cccea70db1
commit 98b21d0fdf
4 changed files with 9 additions and 24 deletions

View File

@@ -1,15 +0,0 @@
package data
import "unsafe"
// Str2bytes Fast convert
func Str2bytes(s string) []byte {
x := (*[2]uintptr)(unsafe.Pointer(&s))
h := [3]uintptr{x[0], x[1], x[1]}
return *(*[]byte)(unsafe.Pointer(&h))
}
// Bytes2str Fast convert
func Bytes2str(b []byte) string {
return *(*string)(unsafe.Pointer(&b))
}