Skip to content

Commit

Permalink
Use u8 in a few more places (dotnet#70568)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub authored Jun 11, 2022
1 parent 55ed5e8 commit 35717a3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ internal async Task WriteWebSocketHandshakeHeadersAsync()
}
}

private static byte[] s_crlf = new byte[] { 13, 10 };
private static readonly byte[] s_crlf = "\r\n"u8.ToArray();
private static byte[] GetChunkSizeBytes(int size, bool final) =>
Encoding.ASCII.GetBytes($"{size:x}\r\n{(final ? "\r\n" : "")}");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,14 +376,7 @@ static string GetDeflateOptions(WebSocketDeflateOptions options)
private static KeyValuePair<string, string> CreateSecKeyAndSecWebSocketAccept()
{
// GUID appended by the server as part of the security key response. Defined in the RFC.
ReadOnlySpan<byte> wsServerGuidBytes = new byte[]
{
(byte)'2', (byte)'5', (byte)'8', (byte)'E', (byte)'A', (byte)'F', (byte)'A', (byte)'5', (byte)'-',
(byte)'E', (byte)'9', (byte)'1', (byte)'4', (byte)'-',
(byte)'4', (byte)'7', (byte)'D', (byte)'A', (byte)'-',
(byte)'9', (byte)'5', (byte)'C', (byte)'A', (byte)'-',
(byte)'C', (byte)'5', (byte)'A', (byte)'B', (byte)'0', (byte)'D', (byte)'C', (byte)'8', (byte)'5', (byte)'B', (byte)'1', (byte)'1'
};
ReadOnlySpan<byte> wsServerGuidBytes = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"u8;

Span<byte> bytes = stackalloc byte[24 /* Base64 guid length */ + wsServerGuidBytes.Length];

Expand Down
6 changes: 1 addition & 5 deletions src/libraries/System.Private.CoreLib/src/System/IO/Path.cs
Original file line number Diff line number Diff line change
Expand Up @@ -816,11 +816,7 @@ private static unsafe string JoinInternal(ReadOnlySpan<char> first, ReadOnlySpan
}
}

private static ReadOnlySpan<byte> Base32Char => new byte[32] { // uses C# compiler's optimization for static byte[] data
(byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', (byte)'f', (byte)'g', (byte)'h',
(byte)'i', (byte)'j', (byte)'k', (byte)'l', (byte)'m', (byte)'n', (byte)'o', (byte)'p',
(byte)'q', (byte)'r', (byte)'s', (byte)'t', (byte)'u', (byte)'v', (byte)'w', (byte)'x',
(byte)'y', (byte)'z', (byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4', (byte)'5' };
private static ReadOnlySpan<byte> Base32Char => "abcdefghijklmnopqrstuvwxyz012345"u8;

private static unsafe void Populate83FileNameFromRandomBytes(byte* bytes, int byteCount, Span<char> chars)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,7 @@ public partial class MetadataReader
{
internal const string ClrPrefix = "<CLR>";

internal static readonly byte[] WinRTPrefix = new[] {
(byte)'<',
(byte)'W',
(byte)'i',
(byte)'n',
(byte)'R',
(byte)'T',
(byte)'>'
};
internal static readonly byte[] WinRTPrefix = "<WinRT>"u8.ToArray();

#region Projection Tables

Expand Down

0 comments on commit 35717a3

Please sign in to comment.