From 96c058011f8ab7255fa6f515ba8da60fcb01b4b6 Mon Sep 17 00:00:00 2001 From: Nicolas Portmann Date: Thu, 6 Aug 2020 08:43:11 +0200 Subject: [PATCH 1/2] Revert the use of the public hex encoding API to avoid its overhead --- .../src/System/Net/NetworkInformation/PhysicalAddress.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/PhysicalAddress.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/PhysicalAddress.cs index f2203d56bfe080..ac4cfb0ffcc185 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/PhysicalAddress.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/PhysicalAddress.cs @@ -90,7 +90,7 @@ public override bool Equals(object? comparand) public override string ToString() { - return Convert.ToHexString(_address.AsSpan()); + return HexConverter.ToString(_address.AsSpan(), HexConverter.Casing.Upper); } public byte[] GetAddressBytes() From 26e7276a7cfcd48b34afe251ef050b7cd269ffa5 Mon Sep 17 00:00:00 2001 From: Nicolas Portmann Date: Sat, 8 Aug 2020 15:51:17 +0200 Subject: [PATCH 2/2] Encourage inlining to avoid additional call introduced in #39702 --- src/libraries/Common/src/System/HexConverter.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libraries/Common/src/System/HexConverter.cs b/src/libraries/Common/src/System/HexConverter.cs index d0cd3f074dc008..836145c73d71f8 100644 --- a/src/libraries/Common/src/System/HexConverter.cs +++ b/src/libraries/Common/src/System/HexConverter.cs @@ -83,6 +83,7 @@ public static void ToCharsBuffer(byte value, Span buffer, int startingInde buffer[startingIndex] = (char)(packedResult >> 8); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void EncodeToUtf16(ReadOnlySpan bytes, Span chars, Casing casing = Casing.Upper) { Debug.Assert(chars.Length >= bytes.Length * 2);