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

Add encodingToStrictByteString #989

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add encodingToStrictByteString #989

wants to merge 1 commit into from

Conversation

phadej
Copy link
Collaborator

@phadej phadej commented Jan 20, 2023

This runs Builder to produce Strict ByteString directly, by making a mutable buffer and growing it exponentially.

This might be good or bad, better or worse than
LBS.toStrict . encodingToLazyByteString.
Latter allocates many small chunks, and copies once; encodingToStrictByteString makes a buffer exponentially, but copies data everytime.

TL;DR bytestrings Builder implementation allows to execute it into a contiguous buffer, i.e. strict bytestring.

(We could almost reuse the same trick to produce strict text as well, but we'd need to copy to unpin resulting bytearray)

@phadej phadej requested a review from Lysxia January 20, 2023 15:46
This runs Builder to produce Strict ByteString directly,
by making a mutable buffer and growing it exponentially.

This might be good or bad, better or worse than
LBS.toStrict . encodingToLazyByteString.
Latter allocates many small chunks, and copies once;
encodingToStrictByteString makes a buffer exponentially,
but copies data everytime.
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

Successfully merging this pull request may close these issues.

1 participant