-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Collection expressions: empty Span optimization #70260
Collection expressions: empty Span optimization #70260
Conversation
Love it |
IL_0005: newobj "System.ReadOnlySpan<T>..ctor(T[])" | ||
IL_000a: call "MyCollection<T> MyCollectionBuilder.Create<T>(scoped System.ReadOnlySpan<T>)" | ||
IL_000f: ret | ||
.locals init (System.ReadOnlySpan<T> V_0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we understand why the new codegen involves an additional local and IL instruction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initobj expects an address on the stack. In some cases a new local is introduced in order to provide that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks (iteration 1)
Note: we should do this for 17.8. This is a very trivial change, but important to our messaging about collections and perf. Having a core span scenario work well is high on that list. |
8fc28af
into
dotnet:features/CollectionLiterals
Part of #68785