You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a list of various optimization opportunities I have spotted so far. I'd like to keep it here rather than in the notes that are bound to be eventually lost just in case you may want to consider implementing any of those yourself.
Detect struct/non-interface-based Enumerator GetEnumerator() implementation on types and target it and its return type over IEnumerator<T> GetEnumerator()
Use CollectionsMarshal.AsSpan() and CollectionsMarshal.SetCount() to presize enumerable materialization into lists of potentially known length (where assumed length <= presized length)
I forgot to reply to this the other day, but I think the main challenge in using an array builder would be in how to embed the implementation on the output module. The easiest approach would probably be to add the source on MSBuild task project, and let trimming or whatever deal with them if they're left unused.
The struct enumerator thing could be more easily done when expanding LINQ queries based around enumerator sources, but there are some other stages like SelectMany() that always fallback to the interfaces, so maybe a more generic approach would be beneficial.
This is a list of various optimization opportunities I have spotted so far. I'd like to keep it here rather than in the notes that are bound to be eventually lost just in case you may want to consider implementing any of those yourself.
Enumerator GetEnumerator()
implementation on types and target it and its return type overIEnumerator<T> GetEnumerator()
CollectionsMarshal.AsSpan()
andCollectionsMarshal.SetCount()
to presize enumerable materialization into lists of potentially known length (where assumed length <= presized length)stackalloc
orInlineArray
for initial buffer (with caveats around large structs and managed T)throw
to avoid codegen regressions caused by the presence of EHThe text was updated successfully, but these errors were encountered: