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

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

Open
RikkiGibson opened this issue Apr 19, 2024 · 2 comments
Labels
Area-Compilers Code Gen Quality Room for improvement in the quality of the compiler's generated code help wanted The issue is "up for grabs" - add a comment if you are interested in working on it New Feature - Collection Expressions
Milestone

Comments

@RikkiGibson
Copy link
Contributor

RikkiGibson commented Apr 19, 2024

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);
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 19, 2024
@RikkiGibson RikkiGibson added help wanted The issue is "up for grabs" - add a comment if you are interested in working on it Code Gen Quality Room for improvement in the quality of the compiler's generated code New Feature - Collection Expressions and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 19, 2024
@RikkiGibson RikkiGibson added this to the Backlog milestone Apr 19, 2024
@DoctorKrolic
Copy link
Contributor

Should this apply only to well-known Span type or any collection type with user-defined conversion to ROS, either implicit or explicit? The latter seems pretty reasonable, but I'm not sure whether the spec allows using such arbitrary user-defined members in codegen

@RikkiGibson
Copy link
Contributor Author

I wouldn't use explicit conversions.

I feel like we should use a user defined implicit conversion to ROS no matter which type defines it. It's possible language needs to extend the definition of "well-behavedness" for us to be able to do that. At minimum this should work with spans and arrays.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Code Gen Quality Room for improvement in the quality of the compiler's generated code help wanted The issue is "up for grabs" - add a comment if you are interested in working on it New Feature - Collection Expressions
Projects
None yet
Development

No branches or pull requests

2 participants