Skip to content

Commit 3d5c8ed

Browse files
Use Array.Empty in WebEncoders (#23677)
1 parent df5269f commit 3d5c8ed

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/Hosting/Hosting/src/GenericHost/GenericWebHostedService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ private RequestDelegate BuildErrorPageApplication(Exception exception)
180180
}
181181
else
182182
{
183-
model.ErrorDetails = new ExceptionDetails[0];
183+
model.ErrorDetails = Array.Empty<ExceptionDetails>();
184184
}
185185

186186
var errorPage = new ErrorPage(model);

src/Shared/WebEncoders/WebEncoders.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ namespace Microsoft.Extensions.Internal
2626
#endif
2727
static class WebEncoders
2828
{
29-
private static readonly byte[] EmptyBytes = new byte[0];
30-
3129
/// <summary>
3230
/// Decodes a base64url-encoded string.
3331
/// </summary>
@@ -70,7 +68,7 @@ public static byte[] Base64UrlDecode(string input, int offset, int count)
7068
// Special-case empty input
7169
if (count == 0)
7270
{
73-
return EmptyBytes;
71+
return Array.Empty<byte>();
7472
}
7573

7674
// Create array large enough for the Base64 characters, not just shorter Base64-URL-encoded form.
@@ -117,7 +115,7 @@ public static byte[] Base64UrlDecode(string input, int offset, char[] buffer, in
117115

118116
if (count == 0)
119117
{
120-
return EmptyBytes;
118+
return Array.Empty<byte>();
121119
}
122120

123121
// Assumption: input is base64url encoded without padding and contains no whitespace.

0 commit comments

Comments
 (0)