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
Open
@caibei1

Description

@caibei1

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))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0