Skip to content

Generalize (CollectionBuilderType<T>)[..readOnlySpan] optimization to spread operands which are implicitly convertible to ReadOnlySpan<T> #73110

@RikkiGibson

Description

@RikkiGibson

I would welcome a follow-up PR which also handles cases where the spread operand is implicitly convertible to ReadOnlySpan<T>.

Originally posted by @RikkiGibson in #73102 (comment)

Affected scenarios would include:

Span<int> span = ..;
MyCollectionBuilderType<T> collection = [..span];

// currently:
MyCollectionBuilderType<T> collection = MyCollectionBuilderType.Create((ReadOnlySpan<T>)span.ToArray());

// could change to:
MyCollectionBuilderType<T> collection = MyCollectionBuilderType.Create((ReadOnlySpan<T>)span);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-CompilersCode Gen QualityRoom for improvement in the quality of the compiler's generated codeFeature - Collection Expressionshelp wantedThe issue is "up for grabs" - add a comment if you are interested in working on it

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions