You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I see that when I convert the slice into a byte array, I traverse it. If you can judge the slice length here, when the slice length is too large, consider using other conversion methods.
for example:
arr is a big slice.
arr := make([]float32,1000)
header := *(*reflect.SliceHeader)(unsafe.Pointer(&arr))
header.Len = len(arr) * 4
header.Cap = header.Len
bytes := ([]byte)(unsafe.Pointer(&header))
The text was updated successfully, but these errors were encountered:
caibei1
changed the title
关于大切片的优化
On the optimization of large slice
Jan 18, 2021
I see that when I convert the slice into a byte array, I traverse it. If you can judge the slice length here, when the slice length is too large, consider using other conversion methods.
for example:
arr is a big slice.
arr := make([]float32,1000)
header := *(*reflect.SliceHeader)(unsafe.Pointer(&arr))
header.Len = len(arr) * 4
header.Cap = header.Len
bytes := ([]byte)(unsafe.Pointer(&header))
The text was updated successfully, but these errors were encountered: