Browse Source

remove micro optimization and simplify HexStringToBytes

pull/521/head
Siegfried Pammer 11 years ago
parent
commit
2d2c96af34
  1. 14
      ILSpy.AddIn/Utils.cs

14
ILSpy.AddIn/Utils.cs

@ -104,21 +104,9 @@ namespace ICSharpCode.ILSpy.AddIn
{ {
var result = new byte[hex.Length / 2]; var result = new byte[hex.Length / 2];
for (int i = 0; i < hex.Length / 2; i++) { for (int i = 0; i < hex.Length / 2; i++) {
result[i] = (byte)(ParseNibble(hex[i * 2]) * 16 result[i] = Convert.ToByte(hex.Substring(i * 2, 2), 16);
+ ParseNibble(hex[i * 2 + 1]));
} }
return result; return result;
} }
static int ParseNibble(char c)
{
if (c >= '0' && c <= '9')
return c - '0';
if (c >= 'A' && c <= 'F')
return c - 'A' + 10;
if (c >= 'a' && c <= 'f')
return c - 'a' + 10;
throw new ArgumentException("Invalid hex digit: " + c);
}
} }
} }

Loading…
Cancel
Save