-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Data.ByteString.Lazy.Char8.lines less strict
The current implementation of `lines` in Data.ByteString.Lazy.Char8 is too strict. When a "line" spans multiple chunks it traverses all the chunks to the first line boundary before constructing the list head. For example, `lines <$> getContents` reading a large file with no line breaks does not make the first chunk of the (only) line available until the entire file is read into memory. Now that `Data.ByteString.break` is optimised for the `(== c)` case, we can get efficient code for the common many lines per-chunk use-case, without being needlessly strict. Tests added to make sure that the first chunk is available prompty without looking further.
- Loading branch information
Showing
2 changed files
with
64 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters