8000 On the optimization of large slice · Issue #27 · andyleap/gencode · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

On the optimization of large slice #27

New issue

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

Open
caibei1 opened this issue Jan 18, 2021 · 0 comments
Open

On the optimization of large slice #27

caibei1 opened this issue Jan 18, 2021 · 0 comments

Comments

@caibei1
Copy link
caibei1 commented 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))

@caibei1 caibei1 changed the title 关于大切片的优化 On the optimization of large slice Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0