diff --git a/Src/Newtonsoft.Json/Linq/JEnumerable.cs b/Src/Newtonsoft.Json/Linq/JEnumerable.cs index a1cb1f7e..193ebad0 100644 --- a/Src/Newtonsoft.Json/Linq/JEnumerable.cs +++ b/Src/Newtonsoft.Json/Linq/JEnumerable.cs @@ -67,12 +67,7 @@ namespace Newtonsoft.Json.Linq /// public IEnumerator GetEnumerator() { - if (_enumerable == null) - { - return Empty.GetEnumerator(); - } - - return _enumerable.GetEnumerator(); + return (_enumerable ?? Empty).GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() diff --git a/Src/Newtonsoft.Json/Utilities/CollectionWrapper.cs b/Src/Newtonsoft.Json/Utilities/CollectionWrapper.cs index 52f8ce6c..80204c31 100644 --- a/Src/Newtonsoft.Json/Utilities/CollectionWrapper.cs +++ b/Src/Newtonsoft.Json/Utilities/CollectionWrapper.cs @@ -169,24 +169,12 @@ namespace Newtonsoft.Json.Utilities public virtual IEnumerator GetEnumerator() { - if (_genericCollection != null) - { - return _genericCollection.GetEnumerator(); - } - - return _list.Cast().GetEnumerator(); + return (_genericCollection ?? _list.Cast()).GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { - if (_genericCollection != null) - { - return _genericCollection.GetEnumerator(); - } - else - { - return _list.GetEnumerator(); - } + return ((IEnumerable)_genericCollection ?? _list).GetEnumerator(); } int IList.Add(object value) @@ -333,17 +321,7 @@ namespace Newtonsoft.Json.Utilities public object UnderlyingCollection { - get - { - if (_genericCollection != null) - { - return _genericCollection; - } - else - { - return _list; - } - } + get { return (object)_genericCollection ?? _list; } } } } \ No newline at end of file