AsciiByteMap
struct AsciiByteMap
using System.Runtime.CompilerServices;
namespace System.Text.Encodings.Web
{
internal struct AsciiByteMap
{
private unsafe fixed byte Buffer[128];
internal unsafe void InsertAsciiChar(char key, byte value)
{
if (key < '')
*(sbyte*)(ref *Buffer + key) = (sbyte)value;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[IsReadOnly]
internal unsafe bool TryLookup(Rune key, out byte value)
{
if (key.IsAscii) {
byte b = *(byte*)(ref *Buffer + (uint)key.Value);
if (b != 0) {
value = b;
return true;
}
}
value = 0;
return false;
}
}
}