Skip to content

Commit

Permalink
Avoid allocating an array (#55109)
Browse files Browse the repository at this point in the history
  • Loading branch information
vcsjones committed Jul 6, 2021
1 parent 56b250b commit 7e43f8c
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Internal.Cryptography.Pal
internal sealed partial class AppleCertificatePal : ICertificatePal
{
// Byte representation of "-----BEGIN "
private static byte[] pemBegin = new byte[] { 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x20 };
private static ReadOnlySpan<byte> PemBegin => new byte[] { 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x20 };

internal delegate bool DerCallback(ReadOnlySpan<byte> derData, X509ContentType contentType);

Expand All @@ -30,7 +30,7 @@ internal static bool TryDecodePem(ReadOnlySpan<byte> rawData, DerCallback derCal
// Look for the PEM marker. This doesn't guarantee it will be a valid PEM since we don't check whether
// the marker is at the beginning of line or whether the line is a complete marker. It's just a quick
// check to avoid conversion from bytes to characters if the content is DER encoded.
if (rawData.IndexOf(pemBegin) < 0)
if (rawData.IndexOf(PemBegin) < 0)
{
return false;
}
Expand Down

0 comments on commit 7e43f8c

Please sign in to comment.