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

◆ TryParseUInt32X()

static bool System.Buffers.Text.Utf8Parser.TryParseUInt32X ( ReadOnlySpan< byte > source,
out uint value,
out int bytesConsumed )
inlinestaticprivate

Definition at line 3252 of file Utf8Parser.cs.

3253 {
3254 if (source.Length < 1)
3255 {
3256 bytesConsumed = 0;
3257 value = 0u;
3258 return false;
3259 }
3260 ReadOnlySpan<byte> charToHexLookup = HexConverter.CharToHexLookup;
3261 byte index = source[0];
3262 byte b = charToHexLookup[index];
3263 if (b == byte.MaxValue)
3264 {
3265 bytesConsumed = 0;
3266 value = 0u;
3267 return false;
3268 }
3269 uint num = b;
3270 if (source.Length <= 8)
3271 {
3272 for (int i = 1; i < source.Length; i++)
3273 {
3274 index = source[i];
3275 b = charToHexLookup[index];
3276 if (b == byte.MaxValue)
3277 {
3278 bytesConsumed = i;
3279 value = num;
3280 return true;
3281 }
3282 num = (num << 4) + b;
3283 }
3284 }
3285 else
3286 {
3287 for (int j = 1; j < 8; j++)
3288 {
3289 index = source[j];
3290 b = charToHexLookup[index];
3291 if (b == byte.MaxValue)
3292 {
3293 bytesConsumed = j;
3294 value = num;
3295 return true;
3296 }
3297 num = (num << 4) + b;
3298 }
3299 for (int k = 8; k < source.Length; k++)
3300 {
3301 index = source[k];
3302 b = charToHexLookup[index];
3303 if (b == byte.MaxValue)
3304 {
3305 bytesConsumed = k;
3306 value = num;
3307 return true;
3308 }
3309 if (num > 268435455)
3310 {
3311 bytesConsumed = 0;
3312 value = 0u;
3313 return false;
3314 }
3315 num = (num << 4) + b;
3316 }
3317 }
3318 bytesConsumed = source.Length;
3319 value = num;
3320 return true;
3321 }

References System.HexConverter.CharToHexLookup, System.index, System.source, and System.value.

Referenced by System.Buffers.Text.Utf8Parser.TryParse(), System.Buffers.Text.Utf8Parser.TryParse(), System.Buffers.Text.Utf8Parser.TryParseGuidCore(), and System.Buffers.Text.Utf8Parser.TryParseGuidN().