Skip to content

Proposal: grow buffers more efficiently #679

Open
@bboreham

Description

@bboreham

json-iterator is using append in many places to grow a buffer, e.g.:

go/stream.go

Line 68 in 71ac162

stream.buf = append(stream.buf, p...)

return append(buf, byte(v>>16), byte(v>>8), byte(v))

As noted at golang/go#50774, append is designed to minimize space wasted at the end of the buffer, whereas most people using json-iterator probably want to optimise for minimum CPU usage.

I can make a PR, but posting this as an issue first to get feedback.

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