File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -156,28 +156,30 @@ public void AddFront(T value)
156
156
// Note: Some consumers use this Enumerator dynamically to avoid allocations.
157
157
internal struct Enumerator < T > : IEnumerator < T >
158
158
{
159
+ private static readonly DiagNode < T > s_Empty = new DiagNode < T > ( default ! ) ;
160
+
159
161
private DiagNode < T > ? _nextNode ;
160
- [ AllowNull , MaybeNull ] private T _currentItem ;
162
+ private DiagNode < T > _currentNode ;
161
163
162
164
public Enumerator ( DiagNode < T > ? head )
163
165
{
164
166
_nextNode = head ;
165
- _currentItem = default ;
167
+ _currentNode = s_Empty ;
166
168
}
167
169
168
- public T Current => _currentItem ! ;
170
+ public T Current => _currentNode . Value ;
169
171
170
172
object ? IEnumerator . Current => Current ;
171
173
172
174
public bool MoveNext ( )
173
175
{
174
176
if ( _nextNode == null )
175
177
{
176
- _currentItem = default ;
178
+ _currentNode = s_Empty ;
177
179
return false ;
178
180
}
179
181
180
- _currentItem = _nextNode . Value ;
182
+ _currentNode = _nextNode ;
181
183
_nextNode = _nextNode . Next ;
182
184
return true ;
183
185
}
You can’t perform that action at this time.
0 commit comments