-Added IJsonBufferPool, performance stuff

This commit is contained in:
James Newton-King
2015-11-12 22:08:39 +13:00
parent d91e8f4425
commit ac1a46bd14
19 changed files with 425 additions and 70 deletions
@@ -858,5 +858,35 @@ namespace Newtonsoft.Json.Utilities
return Guid.TryParseExact(s, "D", out g);
#endif
}
public static int HexTextToInt(char[] text, int start, int end)
{
int value = 0;
for (int i = start; i < end; i++)
{
value += HexCharToInt(text[i]) << ((end - 1 - i) * 4);
}
return value;
}
private static int HexCharToInt(char ch)
{
if (ch <= 57 && ch >= 48)
{
return ch - 48;
}
if (ch <= 70 && ch >= 65)
{
return ch - 55;
}
if (ch <= 102 && ch >= 97)
{
return ch - 87;
}
throw new FormatException("Invalid hex character: " + ch);
}
}
}