Remove groupBy' for specialized internal splitBothBoth helper#26
Open
ninioArtillero wants to merge 1 commit into
Open
Remove groupBy' for specialized internal splitBothBoth helper#26ninioArtillero wants to merge 1 commit into
groupBy' for specialized internal splitBothBoth helper#26ninioArtillero wants to merge 1 commit into
Conversation
a725ea7 to
e3f1241
Compare
Member
|
This looks good to me. |
e3f1241 to
12fc5af
Compare
Contributor
Author
|
@ddssff Just gave it a last sanity check and just changed two type aliases to better reflect where we expect the |
12fc5af to
c45b66d
Compare
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.
The
groupBy'helper is defined within theData.Algorithm.DiffContextmodule with the purpose of creating separate hunks within thegetContextDiffNumberedfunction.In this PR, this helper is specialized to
Hunk cinstead of arbitrary lists with one variation: the equality predicate argument is removed by (essentially) inlining the predicate used at the call site:\a b -> not (isBoth a && isBoth b). As a consequence, the required split is done throughout the recursive accumulation and consing, and theisBothlocal helper is removed fromgetContextDiffNumbered.This change merges two helpers and reduces the amount of indirection, making the operation in question easier to reason about and the body of
getContextDiffNumberedmore transparent and concise:NOTE: This change passes all
cabal tests and results in no perceptible performance variation oncabal bench(from #25).NOTE: The
groupBy'export is now removed and not replaced by the new function (reason being that the new helper is an implementation detail), thus probably requiring a version bump. The script at the bottom of this description reveals that no module directly importingDiffContextcallsgroupBy'. It might still be the case for a module re-export to hide a call from this script, but this seems very unlikely. A Github search forgroupBy' language:Haskellshows bespoke definitions ofgroupBy'are very common. Besides, this is far from being a loss given that focused alternatives toPrelude.groupBywith equivalent behavior toDiffContext.groupBy'(but perhaps, better performance) exist in the ecosystem: