Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RegexpTransformer: use internal buffering #6

Open
icholy opened this issue Nov 15, 2022 · 0 comments
Open

RegexpTransformer: use internal buffering #6

icholy opened this issue Nov 15, 2022 · 0 comments

Comments

@icholy
Copy link
Owner

icholy commented Nov 15, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant