Optimized Unix2DosFilter to use Span<T>.IndexOf() and CopyTo() #1163
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.
Unfortunately, this optimization is not all rainbows and sunshine.
For short lines, and especially the pathological cases where the input is nothing but "\n\n\n\n..." or "\r\n\r\n\r\n...", performance really suffers with this patch (as seen in the benchmark results below).
Holding off on merging this until I can think up a better solution that is better in all cases (or at least not significantly worse in the pathological cases).
BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.3775) Intel Core i7-9700 CPU 3.00GHz, 1 CPU, 8 logical and 8 physical cores .NET SDK 9.0.300-preview.0.25177.5
[Host] : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2
DefaultJob : .NET 8.0.15 (8.0.1525.16413), X64 RyuJIT AVX2