Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetIndexOfFirstNonAsciiByte_Default()

static unsafe nuint System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte_Default ( byte * pBuffer,
nuint bufferLength )
inlinestaticprivate

Definition at line 56 of file ASCIIUtility.cs.

57 {
58 byte* ptr = pBuffer;
59 if (Vector.IsHardwareAccelerated && bufferLength >= (uint)(2 * Vector<sbyte>.Count))
60 {
61 uint count = (uint)Vector<sbyte>.Count;
62 if (Vector.GreaterThanOrEqualAll(Unsafe.ReadUnaligned<Vector<sbyte>>(pBuffer), Vector<sbyte>.Zero))
63 {
64 byte* ptr2 = pBuffer + bufferLength - count;
65 pBuffer = (byte*)((nuint)(pBuffer + count) & ~(nuint)(count - 1));
66 while (!Vector.LessThanAny(Unsafe.Read<Vector<sbyte>>(pBuffer), Vector<sbyte>.Zero))
67 {
68 pBuffer += count;
69 if (pBuffer > ptr2)
70 {
71 break;
72 }
73 }
74 bufferLength -= (nuint)pBuffer;
75 bufferLength = (nuint)(bufferLength + ptr);
76 }
77 }
78 while (true)
79 {
80 uint num;
81 if (bufferLength >= 8)
82 {
83 num = Unsafe.ReadUnaligned<uint>(pBuffer);
84 uint num2 = Unsafe.ReadUnaligned<uint>(pBuffer + 4);
85 if (!AllBytesInUInt32AreAscii(num | num2))
86 {
88 {
89 num = num2;
90 pBuffer += 4;
91 }
92 goto IL_0100;
93 }
94 pBuffer += 8;
95 bufferLength -= 8;
96 continue;
97 }
98 if ((bufferLength & 4) != 0)
99 {
100 num = Unsafe.ReadUnaligned<uint>(pBuffer);
101 if (!AllBytesInUInt32AreAscii(num))
102 {
103 goto IL_0100;
104 }
105 pBuffer += 4;
106 }
107 if ((bufferLength & 2) != 0)
108 {
109 num = Unsafe.ReadUnaligned<ushort>(pBuffer);
110 if (!AllBytesInUInt32AreAscii(num) && BitConverter.IsLittleEndian)
111 {
112 goto IL_0100;
113 }
114 pBuffer += 2;
115 }
116 if ((bufferLength & 1) != 0 && *pBuffer >= 0)
117 {
118 pBuffer++;
119 }
120 break;
121 IL_0100:
123 break;
124 }
125 return (nuint)(pBuffer - (nuint)ptr);
126 }
static Vector< T > Zero
Definition Vector.cs:874
static bool IsHardwareAccelerated
Definition Vector.cs:14
static uint CountNumberOfLeadingAsciiBytesFromUInt32WithSomeNonAsciiData(uint value)
static bool AllBytesInUInt32AreAscii(uint value)

References System.Text.ASCIIUtility.AllBytesInUInt32AreAscii(), System.count, System.Numerics.Vector< T >.Count, System.Text.ASCIIUtility.CountNumberOfLeadingAsciiBytesFromUInt32WithSomeNonAsciiData(), System.Numerics.Vector< T >.IsHardwareAccelerated, System.BitConverter.IsLittleEndian, and System.Numerics.Vector< T >.Zero.

Referenced by System.Text.ASCIIUtility.GetIndexOfFirstNonAsciiByte().