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

◆ TryParseUInt64X()

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

Definition at line 3323 of file Utf8Parser.cs.

3324 {
3325 if (source.Length < 1)
3326 {
3327 bytesConsumed = 0;
3328 value = 0uL;
3329 return false;
3330 }
3331 ReadOnlySpan<byte> charToHexLookup = HexConverter.CharToHexLookup;
3332 byte index = source[0];
3333 byte b = charToHexLookup[index];
3334 if (b == byte.MaxValue)
3335 {
3336 bytesConsumed = 0;
3337 value = 0uL;
3338 return false;
3339 }
3340 ulong num = b;
3341 if (source.Length <= 16)
3342 {
3343 for (int i = 1; i < source.Length; i++)
3344 {
3345 index = source[i];
3346 b = charToHexLookup[index];
3347 if (b == byte.MaxValue)
3348 {
3349 bytesConsumed = i;
3350 value = num;
3351 return true;
3352 }
3353 num = (num << 4) + b;
3354 }
3355 }
3356 else
3357 {
3358 for (int j = 1; j < 16; j++)
3359 {
3360 index = source[j];
3361 b = charToHexLookup[index];
3362 if (b == byte.MaxValue)
3363 {
3364 bytesConsumed = j;
3365 value = num;
3366 return true;
3367 }
3368 num = (num << 4) + b;
3369 }
3370 for (int k = 16; k < source.Length; k++)
3371 {
3372 index = source[k];
3373 b = charToHexLookup[index];
3374 if (b == byte.MaxValue)
3375 {
3376 bytesConsumed = k;
3377 value = num;
3378 return true;
3379 }
3380 if (num > 1152921504606846975L)
3381 {
3382 bytesConsumed = 0;
3383 value = 0uL;
3384 return false;
3385 }
3386 num = (num << 4) + b;
3387 }
3388 }
3389 bytesConsumed = source.Length;
3390 value = num;
3391 return true;
3392 }

References System.HexConverter.CharToHexLookup, System.index, System.L, 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().