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

◆ TryBestFit()

char System.Text.InternalDecoderBestFitFallbackBuffer.TryBestFit ( byte[] bytesCheck)
inlineprivate

Definition at line 102 of file InternalDecoderBestFitFallbackBuffer.cs.

103 {
104 int num = 0;
105 int num2 = _oFallback.arrayBestFit.Length;
106 if (num2 == 0)
107 {
108 return '\0';
109 }
110 if (bytesCheck.Length == 0 || bytesCheck.Length > 2)
111 {
112 return '\0';
113 }
114 char c = ((bytesCheck.Length != 1) ? ((char)((bytesCheck[0] << 8) + bytesCheck[1])) : ((char)bytesCheck[0]));
115 if (c < _oFallback.arrayBestFit[0] || c > _oFallback.arrayBestFit[num2 - 2])
116 {
117 return '\0';
118 }
119 int num3;
120 while ((num3 = num2 - num) > 6)
121 {
122 int num4 = (num3 / 2 + num) & 0xFFFE;
123 char c2 = _oFallback.arrayBestFit[num4];
124 if (c2 == c)
125 {
126 return _oFallback.arrayBestFit[num4 + 1];
127 }
128 if (c2 < c)
129 {
130 num = num4;
131 }
132 else
133 {
134 num2 = num4;
135 }
136 }
137 for (int num4 = num; num4 < num2; num4 += 2)
138 {
139 if (_oFallback.arrayBestFit[num4] == c)
140 {
141 return _oFallback.arrayBestFit[num4 + 1];
142 }
143 }
144 return '\0';
145 }

References System.Text.InternalDecoderBestFitFallbackBuffer._oFallback, and System.Text.InternalDecoderBestFitFallback.arrayBestFit.

Referenced by System.Text.InternalDecoderBestFitFallbackBuffer.Fallback().