Refactor Encoding to split fast-path and fallback logic (#23098)
authorLevi Broderick <GrabYourPitchforks@users.noreply.github.com>
Mon, 11 Mar 2019 04:40:27 +0000 (21:40 -0700)
committerGitHub <noreply@github.com>
Mon, 11 Mar 2019 04:40:27 +0000 (21:40 -0700)
commit43a5159d39bd52195c5095da4006183f791c696b
treea7a4161a8e280fc68927bee1511002ec7a7ea550
parent60773aa089840f5e944d3f72969cde0561b9135b
Refactor Encoding to split fast-path and fallback logic (#23098)

This refactoring is limited to ASCIIEncoding at the moment, but it can easily be applied to UTF-8 / UTF-16 / UTF-32.

High-level changes:
- Fallback logic has been split from the fast-path, improving performance of GetBytes and similar routines.
- All of the plumbing of when to invoke the fallback logic and how to manage leftover data has been moved into the base class.
- Almost all of the logic except for the fast-path is now written in terms of verifiable code (Span and ReadOnlySpan).
- Minor bug fixes in EncoderNLS.Convert (see https://github.com/dotnet/coreclr/issues/23020).
13 files changed:
src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems
src/System.Private.CoreLib/shared/System/String.cs
src/System.Private.CoreLib/shared/System/Text/ASCIIEncoding.cs
src/System.Private.CoreLib/shared/System/Text/ASCIIUtility.cs [new file with mode: 0644]
src/System.Private.CoreLib/shared/System/Text/DecoderFallback.cs
src/System.Private.CoreLib/shared/System/Text/DecoderNLS.cs
src/System.Private.CoreLib/shared/System/Text/EncoderFallback.cs
src/System.Private.CoreLib/shared/System/Text/EncoderNLS.cs
src/System.Private.CoreLib/shared/System/Text/Encoding.Internal.cs [new file with mode: 0644]
src/System.Private.CoreLib/shared/System/Text/Encoding.cs
src/System.Private.CoreLib/shared/System/Text/EncodingNLS.cs
src/System.Private.CoreLib/shared/System/ThrowHelper.cs
tests/CoreFX/CoreFX.issues.json