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

Avoid some allocations #2079

Merged
merged 2 commits into from
Jan 10, 2024
Merged

Avoid some allocations #2079

merged 2 commits into from
Jan 10, 2024

Conversation

MarcoRossignoli
Copy link
Contributor

No description provided.

@MarcoRossignoli MarcoRossignoli marked this pull request as draft January 10, 2024 09:31
@MarcoRossignoli MarcoRossignoli marked this pull request as ready for review January 10, 2024 09:33
@MarcoRossignoli MarcoRossignoli merged commit 3ae8c27 into main Jan 10, 2024
3 of 6 checks passed
@MarcoRossignoli MarcoRossignoli deleted the dev/mr/nitpick branch January 10, 2024 09:51

internal static class IEnumerableExtensions
{
public static IReadOnlyCollection<T> ToReadOnlyCollectionEnumerator<T>(this IEnumerable<T> enumerable)
Copy link
Member

Choose a reason for hiding this comment

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

The method suggests that it is returning an enumerator but that's not the case. I would prefer ToReadOnlyCollection.

{
private readonly IEnumerable<T> _enumerable = enumerable;

public int Count => _enumerable.Count();
Copy link
Member

Choose a reason for hiding this comment

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

Isn't it better to persist the count so it's not performing the enumeration foreach everytime?

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

Successfully merging this pull request may close these issues.

None yet

2 participants