diff --git a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/LockFreeReaderHashtable.cs b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/LockFreeReaderHashtable.cs index 44be986803b66f..613ec30fa01d2e 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/Utilities/LockFreeReaderHashtable.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/Utilities/LockFreeReaderHashtable.cs @@ -689,27 +689,24 @@ internal Enumerator(LockFreeReaderHashtable hashtable) public bool MoveNext() { - if (_sentinel != null) + if ((_sentinel != null) && (_hashtableContentsToEnumerate != null)) { - if ((_hashtableContentsToEnumerate != null) && (_index < _hashtableContentsToEnumerate.Length)) + for (; _index < _hashtableContentsToEnumerate.Length; _index++) { - for (; _index < _hashtableContentsToEnumerate.Length; _index++) + if ((_hashtableContentsToEnumerate[_index] != null) && (_hashtableContentsToEnumerate[_index] != _sentinel)) { - if ((_hashtableContentsToEnumerate[_index] != null) && (_hashtableContentsToEnumerate[_index] != _sentinel)) - { - _current = _hashtableContentsToEnumerate[_index]; - _index++; - return true; - } + _current = _hashtableContentsToEnumerate[_index]; + _index++; + return true; } } - } - if ((_index == _hashtableContentsToEnumerate.Length) && _sentinel != null) - { - _current = _sentinel; - _index++; - return true; + if (_index == _hashtableContentsToEnumerate.Length) + { + _current = _sentinel; + _index++; + return true; + } } _current = default(TValue);