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

FillBackward overloads without a fillSelector are not optimal #678

Open
Orace opened this issue Nov 9, 2019 · 0 comments
Open

FillBackward overloads without a fillSelector are not optimal #678

Orace opened this issue Nov 9, 2019 · 0 comments

Comments

@Orace
Copy link
Contributor

Orace commented Nov 9, 2019

If fillSelector is null the blanks list is created and filled but it's never used.

List<T> blanks = null;
foreach (var item in source)
{
var isBlank = predicate(item);
if (isBlank)
{
(blanks ??= new List<T>()).Add(item);
}
else
{
if (blanks != null)
{
foreach (var blank in blanks)
{
yield return fillSelector != null
? fillSelector(blank, item)
: item;
}

@Orace Orace changed the title FillBackward overloads without a fillSelector are no optimals FillBackward overloads without a fillSelector are not optimals Nov 9, 2019
@atifaziz atifaziz changed the title FillBackward overloads without a fillSelector are not optimals FillBackward overloads without a fillSelector are not optimal Jan 14, 2023
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

No branches or pull requests

1 participant