Refactor Encoding to split fast-path and fallback logic (dotnet/coreclr#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)
commit2883820e5bd4a0ff62fad46c8e6c4721d4151f83
treed0eb539a236360af2625833a909f84dd1e94bf02
parent8d27a06d4767a7656058614a20c8e220f0a58d4d
Refactor Encoding to split fast-path and fallback logic (dotnet/coreclr#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).

Commit migrated from https://github.com/dotnet/coreclr/commit/43a5159d39bd52195c5095da4006183f791c696b
13 files changed:
src/coreclr/tests/CoreFX/CoreFX.issues.json
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
src/libraries/System.Private.CoreLib/src/System/String.cs
src/libraries/System.Private.CoreLib/src/System/Text/ASCIIEncoding.cs
src/libraries/System.Private.CoreLib/src/System/Text/ASCIIUtility.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System/Text/DecoderFallback.cs
src/libraries/System.Private.CoreLib/src/System/Text/DecoderNLS.cs
src/libraries/System.Private.CoreLib/src/System/Text/EncoderFallback.cs
src/libraries/System.Private.CoreLib/src/System/Text/EncoderNLS.cs
src/libraries/System.Private.CoreLib/src/System/Text/Encoding.Internal.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System/Text/Encoding.cs
src/libraries/System.Private.CoreLib/src/System/Text/EncodingNLS.cs
src/libraries/System.Private.CoreLib/src/System/ThrowHelper.cs