Skip to content

Investigate benefits of separating out parts of Count into a non-generic method. #19393

@jamesqo

Description

@jamesqo

Separated out from dotnet/corefx#12703. Relevant discussion: dotnet/corefx#12703 (comment)

tl;dr We may want to put a part of Enumerable.Count<T> in a non-generic method so that the JIT has less code to generate during the following 2 scenarios:

  • For a particular value type T, the source enumerable always implements ICollection, IIListProvider, etc. and we can determine the count without actually enumerating

  • We fall back to iterating manually over the enumerable for at least 2 different value types

More details can be found in the comment linked to. Opening this as a tracking issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.LinqenhancementProduct code improvement that does NOT require public API changes/additionshelp wanted[up-for-grabs] Good issue for external contributorstenet-performancePerformance related issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions