We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
func Unmarshal(buf []byte, val interface{}) error { return sonic.UnmarshalString(*(*string)(unsafe.Pointer(&buf)), val) }
使用*(*string)(unsafe.Pointer(&buf))而不是string(buf),以减少内存分配。
*(*string)(unsafe.Pointer(&buf))
string(buf)
假如考虑到byte数组的安全性,我认为不需要担心,使用sonic框架后,正常调用都是通过sonic.UnmarshalString完成的,项目中很少会用到sonic.Unmarshal。很多时候用到byte数组的序列化都是因为需要替换其他框架的序列化方式。
sonic.UnmarshalString
sonic.Unmarshal
The text was updated successfully, but these errors were encountered:
刻意这么设计的,为了和标准库保持一定兼容性。我们没办法保证别人不去修改 []byte 的内容。关于 UnmarshalString 这个已经在 README.md 中写得比较清楚了的。
UnmarshalString
Sorry, something went wrong.
No branches or pull requests
使用
*(*string)(unsafe.Pointer(&buf))
而不是string(buf)
,以减少内存分配。假如考虑到byte数组的安全性,我认为不需要担心,使用sonic框架后,正常调用都是通过
sonic.UnmarshalString
完成的,项目中很少会用到sonic.Unmarshal
。很多时候用到byte数组的序列化都是因为需要替换其他框架的序列化方式。The text was updated successfully, but these errors were encountered: