Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
AllowedBmpCodePointsBitmap.cs
Go to the documentation of this file.
5
7
9{
10 private unsafe fixed uint Bitmap[2048];
11
12 [MethodImpl(MethodImplOptions.AggressiveInlining)]
13 public unsafe void AllowChar(char value)
14 {
16 ref uint reference = ref Bitmap[(ulong)index];
17 reference |= (uint)(1 << offset);
18 }
19
20 [MethodImpl(MethodImplOptions.AggressiveInlining)]
21 public unsafe void ForbidChar(char value)
22 {
24 ref uint reference = ref Bitmap[(ulong)index];
25 reference &= (uint)(~(1 << offset));
26 }
27
29 {
30 ForbidChar('<');
31 ForbidChar('>');
32 ForbidChar('&');
33 ForbidChar('\'');
34 ForbidChar('"');
35 ForbidChar('+');
36 }
37
38 public unsafe void ForbidUndefinedCharacters()
39 {
40 fixed (uint* pointer = Bitmap)
41 {
43 Span<uint> span = new Span<uint>(pointer, 2048);
45 {
46 while (!values.IsEmpty)
47 {
48 (new Vector<uint>(values) & new Vector<uint>(span)).CopyTo(span);
49 values = values.Slice(Vector<byte>.Count);
50 span = span.Slice(Vector<uint>.Count);
51 }
52 return;
53 }
54 for (int i = 0; i < span.Length; i++)
55 {
56 span[i] &= BinaryPrimitives.ReadUInt32LittleEndian(values.Slice(i * 4));
57 }
58 }
59 }
60
61 [MethodImpl(MethodImplOptions.AggressiveInlining)]
62 public unsafe readonly bool IsCharAllowed(char value)
63 {
65 if ((Bitmap[(ulong)index] & (uint)(1 << offset)) != 0)
66 {
67 return true;
68 }
69 return false;
70 }
71
72 [MethodImpl(MethodImplOptions.AggressiveInlining)]
73 public unsafe readonly bool IsCodePointAllowed(uint value)
74 {
76 {
77 return false;
78 }
80 if ((Bitmap[(ulong)index] & (uint)(1 << offset)) != 0)
81 {
82 return true;
83 }
84 return false;
85 }
86
87 [MethodImpl(MethodImplOptions.AggressiveInlining)]
88 private static void _GetIndexAndOffset(uint value, out nuint index, out int offset)
89 {
90 index = value >> 5;
91 offset = (int)(value & 0x1F);
92 }
93}
static readonly bool IsLittleEndian
static uint ReadUInt32LittleEndian(ReadOnlySpan< byte > source)
static bool IsHardwareAccelerated
Definition Vector.cs:14
static bool IsBmpCodePoint(uint value)
static ReadOnlySpan< byte > GetDefinedBmpCodePointsBitmapLittleEndian()
Span< T > Slice(int start)
Definition Span.cs:271
int Length
Definition Span.cs:70
static void _GetIndexAndOffset(uint value, out nuint index, out int offset)