Copy-avoidance optimizations on Combinatorics #981
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Support
[ReadOnly]Span
, because unlike arrays, it cannot be cast toIEnumerable
without an extra copy.Memory
has a Span property that does not copy so no need to add a version for it. Note thatSpan
only support .Net Core 2.1 and later versions on this line. Framework, Standard (except the rarely used Standard 2.1) and UWP don't support Span.Extend arrays to
I[ReadOnly]List
. For arrays this interface behaves identically, but it can also support other implementations without an extra copy. For example, SelectPermutationInplace could only perform on the full range of an array - it was not possible to permute only a segment of the array. Now you can create anArraySegment
, which implementsIList
, and pass it to SelectPermutationInplace. Only the range specified when creating theArraySegment
will be permuted. You can also passArraySegment
to other similar functions. This is more efficient than Skip-Take in that it does not copy.Add an InPlace version of
SelectVariation
to save a copy if the caller allows modifications on the input data.