Skip to content

Commit

Permalink
Apply Tanner's suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-safar committed Jan 15, 2020
1 parent 22b1e8a commit 463ec5d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/libraries/Common/src/System/HexConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,28 @@ public static unsafe string ToString(ReadOnlySpan<byte> bytes, Casing casing = C
public static char ToCharUpper(int value)
{
value &= 0xF;
return (char)(value > 9 ? value - 10 + 'A' : value + '0');
value += '0';

if (value > '9')
{
value += ('A' - '0');
}

return (char)value;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static char ToCharLower(int value)
{
value &= 0xF;
return (char)(value > 9 ? value - 10 + 'a' : value + '0');
value += '0';

if (value > '9')
{
value += ('a' - '0');
}

return (char)value;
}
}
}

0 comments on commit 463ec5d

Please sign in to comment.