Replace is-and-cast with as-and-nullcheck

Gives slightly better performance, so applying across the board
adds up.
This commit is contained in:
Jon Hanna
2017-01-05 01:52:04 +00:00
parent 306c3a812b
commit a95665b481
16 changed files with 136 additions and 109 deletions
+5 -7
View File
@@ -483,17 +483,15 @@ namespace Newtonsoft.Json
if (Value != null)
{
string s;
if (Value is IFormattable)
IFormattable formattable = Value as IFormattable;
if (formattable != null)
{
s = ((IFormattable)Value).ToString(null, Culture);
}
else if (Value is Uri)
{
s = ((Uri)Value).OriginalString;
s = formattable.ToString(null, Culture);
}
else
{
s = Value.ToString();
Uri uri = Value as Uri;
s = uri != null ? uri.OriginalString : Value.ToString();
}
SetToken(JsonToken.String, s, false);