Remove Unused Encoding on UriHelper
authorEric Erhardt <eric.erhardt@microsoft.com>
Mon, 14 Feb 2022 19:40:45 +0000 (13:40 -0600)
committergithub-actions <github-actions@github.com>
Mon, 14 Feb 2022 20:15:55 +0000 (20:15 +0000)
This field was a left-over artifact from conflicts between the commits:
- https://github.com/dotnet/runtime/commit/70c070e84c617de0700612d03c5886e548195bed
- https://github.com/dotnet/runtime/commit/e53e5430c199c210b7d6f7ce508fb5fabb5faeba

In profiling the startup of a Maui Android app, this initialization is pulling in UTF32 and Latin1 encodings. The profile indicates this accounts for 7ms (roughly 1%). Removing this unnecessary field eliminates 7ms in a Maui App's InitializeComponent.

src/libraries/System.Private.Uri/src/System/UriHelper.cs

index 660d15d..0165a49 100644 (file)
@@ -4,15 +4,11 @@
 using System.Text;
 using System.Diagnostics;
 using System.Runtime.InteropServices;
-using System.Buffers;
 
 namespace System
 {
     internal static class UriHelper
     {
-        internal static readonly Encoding s_noFallbackCharUTF8 = Encoding.GetEncoding(
-            Encoding.UTF8.CodePage, new EncoderReplacementFallback(""), new DecoderReplacementFallback(""));
-
         // http://host/Path/Path/File?Query is the base of
         //      - http://host/Path/Path/File/ ...    (those "File" words may be different in semantic but anyway)
         //      - http://host/Path/Path/#Fragment