Skip to content

proposal: encoding: BinaryMarshaler should be an append API #24630

@FiloSottile

Description

@FiloSottile

The BinaryMarshaler API returns a freshly allocated byte slice. This makes it unadvisable to implement for high performance APIs, or even APIs that could happen to be used in high performance scenarios.

If it had an append-like API (MarshalBinary([]byte) ([]byte, error)) then also a lot of high performance and internal parsing operations could be BinaryMarshaler implementations, allowing more standard interface reuse.

The usability is not much worse, as nil can be passed to get the exact same behavior, and there's precedent in hash.Hash.Sum.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Proposalv2An incompatible library change

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions