Use Array.Empty in WebEncoders (#23677)

This commit is contained in:
Martin Costello 2020-07-05 21:11:36 +01:00 committed by GitHub
parent df5269fea2
commit 3d5c8ed114
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View File

@ -180,7 +180,7 @@ namespace Microsoft.AspNetCore.Hosting
}
else
{
model.ErrorDetails = new ExceptionDetails[0];
model.ErrorDetails = Array.Empty<ExceptionDetails>();
}
var errorPage = new ErrorPage(model);

View File

@ -26,8 +26,6 @@ namespace Microsoft.Extensions.Internal
#endif
static class WebEncoders
{
private static readonly byte[] EmptyBytes = new byte[0];
/// <summary>
/// Decodes a base64url-encoded string.
/// </summary>
@ -70,7 +68,7 @@ namespace Microsoft.Extensions.Internal
// Special-case empty input
if (count == 0)
{
return EmptyBytes;
return Array.Empty<byte>();
}
// Create array large enough for the Base64 characters, not just shorter Base64-URL-encoded form.
@ -117,7 +115,7 @@ namespace Microsoft.Extensions.Internal
if (count == 0)
{
return EmptyBytes;
return Array.Empty<byte>();
}
// Assumption: input is base64url encoded without padding and contains no whitespace.