Skip to content

Commit 8014e32

Browse files
Beautify
(... and remove duplicate code)
1 parent 5c136b9 commit 8014e32

File tree

1 file changed

+2
-26
lines changed

1 file changed

+2
-26
lines changed

Log.cs

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,7 @@ public static string Bits(byte value, bool spaces = true)
2020
public static string Bits<T>(T value, bool spaces = true)
2121
where T : unmanaged
2222
{
23-
byte* address = (byte*)&value;
24-
int sizeInBytes = sizeof(T);
25-
string result = string.Empty;
26-
27-
while (sizeInBytes != 0)
28-
{
29-
result = result.Insert(0, Bits(*address, spaces) + (spaces ? " " : string.Empty));
30-
31-
address++;
32-
sizeInBytes--;
33-
}
34-
35-
return result;
23+
return Bits(&value, sizeof(T), spaces);
3624
}
3725

3826
public static string Bits(void* ptr, int bytes, bool spaces = true)
@@ -63,19 +51,7 @@ public static string Hex(byte value)
6351
public static string Hex<T>(T value, bool spaces = true)
6452
where T : unmanaged
6553
{
66-
byte* address = (byte*)&value;
67-
int iterations = 0;
68-
string result = string.Empty;
69-
70-
while (iterations != sizeof(T))
71-
{
72-
result = result.Insert(0, Hex(*address) + ((spaces && (iterations != 0) && (iterations % 2 == 0)) ? " " : string.Empty));
73-
74-
address++;
75-
iterations++;
76-
}
77-
78-
return result;
54+
return Hex(&value, sizeof(T), spaces);
7955
}
8056

8157
public static string Hex(void* ptr, int bytes, bool spaces = true)

0 commit comments

Comments
 (0)