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

Simplify Fold Implementation #961

Merged
merged 13 commits into from
Feb 26, 2023
Merged

Simplify Fold Implementation #961

merged 13 commits into from
Feb 26, 2023

Conversation

viceroypenguin
Copy link
Contributor

@viceroypenguin viceroypenguin commented Feb 1, 2023

This PR simplifies the implementation of Fold. The existing FoldImpl is unnecessary and onerous to maintain. Since it receives 18 arguments, it must check which one should be non-null and then it must select that one for Folding. This a) creates additional branches and code bloat, and b) adds an additional method that must be maintained.

It is better to have each overload of Fold do what it needs to do directly. This avoids branching and the Assume.NotNull() check, and simplifies the code significantly.

@codecov
Copy link

codecov bot commented Feb 1, 2023

Codecov Report

Merging #961 (8a7def4) into master (aefa90b) will increase coverage by 0.10%.
The diff coverage is 100.00%.

❗ Current head 8a7def4 differs from pull request most recent head 2eb83f7. Consider uploading reports for the commit 2eb83f7 to get more accurate results

@@            Coverage Diff             @@
##           master     #961      +/-   ##
==========================================
+ Coverage   92.49%   92.59%   +0.10%     
==========================================
  Files         113      113              
  Lines        3424     3432       +8     
  Branches     1024     1049      +25     
==========================================
+ Hits         3167     3178      +11     
+ Misses        192      191       -1     
+ Partials       65       63       -2     
Impacted Files Coverage Δ
MoreLinq/Batch.cs 98.07% <100.00%> (+3.73%) ⬆️
MoreLinq/Fold.cs 100.00% <100.00%> (+2.12%) ⬆️
MoreLinq/Fold.g.cs 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@atifaziz atifaziz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments other looks good to merge, thanks!

MoreLinq/Fold.g.tt Outdated Show resolved Hide resolved
MoreLinq/Fold.g.tt Outdated Show resolved Hide resolved
MoreLinq/Fold.g.tt Show resolved Hide resolved
MoreLinq/Fold.g.tt Outdated Show resolved Hide resolved
MoreLinq/Fold.g.tt Outdated Show resolved Hide resolved
Copy link
Member

@atifaziz atifaziz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

MoreLinq/Fold.g.tt Outdated Show resolved Hide resolved
@atifaziz atifaziz merged commit 76c37b3 into morelinq:master Feb 26, 2023
@viceroypenguin viceroypenguin deleted the fold branch February 26, 2023 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants