Skip to content

RegexpTransformer: use internal buffering #6

@icholy

Description

@icholy

The current replace.RegexpTransformer offloads buffering to the calling code. It does this by repeatedly returning transform.ErrShortSrc until enough data is available. Even though this technically conforms to the documentation/contract, it fails when used with transform.Chain due to its internal (undocumented) 2kb buffering limit #5 golang/go#49117.

The replace.Chain was added as an alternative to transform.Chain. However, each call to Chain allocates 8kb for each underlying transform.Reader. I've opened a proposal to add a transform.Reader.Reset method, but the author of x/text is unresponsive.

We can avoid all these problems by doing the buffering ourselves.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions