Skip to content

Suggestion: Use non-allocating APIs #1

@soypat

Description

@soypat

For functions with a fixed output size prefer Write* APIs. For functions with "unbounded" output size prefer Append* APIs like the ones in strconv standard library package.

Examples that come to mind are as follows, also preferring []byte to []int8 because... []byte is Go's preffered unstructured data exchange format

func WsprMessage(...) ([]int8 error)
//becomes
func WriteWSPRMessage(dst []byte, ...) error

func Parity(uint64) []int8
// becomes
func WriteParity([]byte,uint64) error

func interleave([]int8) []int8
// becomes
func interleave([]byte) // Edit in place. No need to allocate, let user allocate if they need a copy of previous data, which does not seem to be the case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions