Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
HexConverter.cs
Go to the documentation of this file.
2
3namespace System;
4
5internal static class HexConverter
6{
7 public static ReadOnlySpan<byte> CharToHexLookup => new byte[256]
8 {
9 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
10 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
11 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
12 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
13 255, 255, 255, 255, 255, 255, 255, 255, 0, 1,
14 2, 3, 4, 5, 6, 7, 8, 9, 255, 255,
15 255, 255, 255, 255, 255, 10, 11, 12, 13, 14,
16 15, 255, 255, 255, 255, 255, 255, 255, 255, 255,
17 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
18 255, 255, 255, 255, 255, 255, 255, 10, 11, 12,
19 13, 14, 15, 255, 255, 255, 255, 255, 255, 255,
20 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
21 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
22 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
23 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
24 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
25 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
26 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
27 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
28 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
29 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
30 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
31 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
32 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
33 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
34 255, 255, 255, 255, 255, 255
35 };
36
37 [MethodImpl(MethodImplOptions.AggressiveInlining)]
38 public static int FromChar(int c)
39 {
40 if (c < CharToHexLookup.Length)
41 {
42 return CharToHexLookup[c];
43 }
44 return 255;
45 }
46
47 [MethodImpl(MethodImplOptions.AggressiveInlining)]
48 public static bool IsHexChar(int c)
49 {
50 if (IntPtr.Size == 8)
51 {
52 ulong num = (uint)(c - 48);
53 ulong num2 = (ulong)(-17875860044349952L << (int)num);
54 ulong num3 = num - 64;
55 if ((long)(num2 & num3) >= 0L)
56 {
57 return false;
58 }
59 return true;
60 }
61 return FromChar(c) != 255;
62 }
63}
static ReadOnlySpan< byte > CharToHexLookup
static bool IsHexChar(int c)
static int FromChar(int c)
static int Size
Definition IntPtr.cs:21