Extend performance group with Text/ByteString strictness hints#1693
Open
mgajda wants to merge 1 commit intondmitchell:masterfrom
Open
Extend performance group with Text/ByteString strictness hints#1693mgajda wants to merge 1 commit intondmitchell:masterfrom
mgajda wants to merge 1 commit intondmitchell:masterfrom
Conversation
Adds same-module, semantics-preserving strict-variant rewrites for Data.Text / Data.ByteString and their Lazy and Char8 variants in the opt-in performance group. All patterns use fully-qualified module names so they only fire on the exact import users actually wrote. - Data.Text.foldl / Data.Text.Lazy.foldl -> foldl' (strict left fold) - Data.ByteString.foldl / Data.ByteString.Lazy.foldl -> foldl' - Data.ByteString.Char8.foldl / Data.ByteString.Lazy.Char8.foldl -> foldl' - Data.Text.concat (map f xs) -> Data.Text.concatMap f xs - Data.Text.Lazy.concat (map f xs) -> Data.Text.Lazy.concatMap f xs Not included: Data.ByteString.concat . map fusion. Data.ByteString's concatMap has signature (Word8 -> ByteString) -> ByteString -> ByteString, so it is NOT the fusion of concat . map over [ByteString]. Nor are any lazy-type-to-strict-type rewrites (e.g. Data.Text.Lazy.pack -> Data.Text.pack) included; those change semantics and would silently break code that needs lazy I/O.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of a set of independent PRs adding rules to the opt-in
performancegroup (disabled by default; enabled via--with-group=performanceor per-project config). Each PR in the settargets a separate rule family and can be reviewed/merged
independently.
This one covers
Data.Text/Data.ByteStringstrict-variant rewrites.Rules added
All matches use fully-qualified module names so they fire only on the
exact lazy imports users wrote (never on Prelude/Foldable
foldl).Data.Text.foldl/Data.Text.Lazy.foldl->foldl'Data.ByteString.foldl/Data.ByteString.Lazy.foldl->foldl'Data.ByteString.Char8.foldl/Data.ByteString.Lazy.Char8.foldl->foldl'Data.Text.concat (map f xs)->Data.Text.concatMap f xsData.Text.Lazy.concat (map f xs)->Data.Text.Lazy.concatMap f xsData.ByteString.concatMaphas a different type(
(Word8 -> ByteString) -> ByteString -> ByteString) so theconcat . mapfusion rule is deliberately NOT applied there.