Skip to content

implement picobuf.Size #26

Description

@egonelbre

Protobuf allows to measure the size of messages. This can be trivially implemented with:

data, err := picobuf.Marshal(msg)
return len(data)

However, it does have significant overheads due to needing the serialization.

There are two ideas how it can be implemented:

A. Generate a separate PicoSize(c *picobuf.Sizer, field picobuf.FieldNumber) or similar. This would allow to generate a significantly more efficient calculation for the size.

B. Modify picobuf.Encoder to allow encoding without appending bytes, but just counting. The specific implementations that don't use the relevant helpers can use: if c.IsSizing() { ... } to short circuit the logic. This might become somewhat complicated, because of the length header for messages.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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