Merge pull request #1125 from JonHanna/null_propogate

Use null-propogation where applicable and useful.
This commit is contained in:
James Newton-King
2017-01-05 11:15:49 +13:00
committed by GitHub
19 changed files with 67 additions and 123 deletions
@@ -253,9 +253,9 @@ namespace Newtonsoft.Json.Utilities
throw new NotSupportedException();
}
#endif
else if (_genericDictionary != null)
else
{
_genericDictionary.Add(item);
_genericDictionary?.Add(item);
}
}
@@ -54,12 +54,7 @@ namespace Newtonsoft.Json.Utilities
public static void ReturnBuffer(IArrayPool<char> bufferPool, char[] buffer)
{
if (bufferPool == null)
{
return;
}
bufferPool.Return(buffer);
bufferPool?.Return(buffer);
}
public static char[] EnsureBufferSize(IArrayPool<char> bufferPool, int size, char[] buffer)
@@ -123,13 +123,7 @@ namespace Newtonsoft.Json.Utilities
return m.GetBaseDefinition();
}
m = propertyInfo.GetSetMethod(true);
if (m != null)
{
return m.GetBaseDefinition();
}
return null;
return propertyInfo.GetSetMethod(true)?.GetBaseDefinition();
}
public static bool IsPublic(PropertyInfo property)