Skip to content

Support lazy construction for byte fields #435

@blackgnezdo

Description

@blackgnezdo

Proto-lens currently generates an API taking strict ByteString for bytes fields. This makes for suboptimal performance because the user is required to make a copy which is then internally turned into a Builder again for serializing the message in Data.ProtoLens.Encoding.Bytes. To avoid breaking the APIs we should introduce alternative lenses for setting the bytes fields to lazy values (or even a Builder). A better API design is welcome.

Internally, we should store a Builder. We'll automatically apply Builder.byteString in generated code. This appears to be efficient so I don't expect any performance regression.

There's a possible continuation of this theme for Text but I don't have a pressing need and the story is not as clear.

@awpr @judah @jinwoo WDYT?

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