Skip to content

Remove unnecessary List<T> instantiation#2588

Merged
davkean merged 2 commits intodotnet:masterfrom
davkean:RemoveList
Oct 5, 2017
Merged

Remove unnecessary List<T> instantiation#2588
davkean merged 2 commits intodotnet:masterfrom
davkean:RemoveList

Conversation

@davkean
Copy link
Copy Markdown
Member

@davkean davkean commented Oct 5, 2017

This was the cause of a large amount (1.2%) of allocations in a large project, some of which end up on the large object heap.

Large project from a partner:
image

Smaller project with mix of .NET Framework/.NET Standard projects:
image

This was the cause of a large amount (1.2%) of allocations in a large project some of which end up on the large object heap.
@davkean
Copy link
Copy Markdown
Member Author

davkean commented Oct 5, 2017

tag @Pilchie

}

public IList<ItemData> GetAllItems()
public IEnumerable<ItemData> GetAllItems()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Might be worth at least commenting that this is deferred, so that callers can be careful about multiple enumerations. Or consider changing the name to make it more clear.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll change the name.

Gives a better indication not to iterate multiple times.
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.

4 participants