File tree Expand file tree Collapse file tree 1 file changed +5
-12
lines changed
Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -14,24 +14,18 @@ public struct ArrayStructEnumerator<T> : IEnumerator<T>
1414 public ArrayStructEnumerator ( ref T [ ] array )
1515 {
1616 this . array = array ;
17- endIndex = array . Length ;
18- index = 0 ;
19- Current = default ;
17+ endIndex = array . Length - 1 ;
18+ index = - 1 ;
2019 }
2120 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
2221 public bool MoveNext ( )
2322 {
24- if ( index >= endIndex )
25- return false ;
26- Current = array [ index ] ;
27- ++ index ;
28- return true ;
23+ return ++ index <= endIndex ;
2924 }
3025 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
3126 public void Reset ( )
3227 {
33- index = 0 ;
34- Current = default ;
28+ index = - 1 ;
3529 }
3630 object IEnumerator . Current => Current ;
3731
@@ -42,8 +36,7 @@ public void Dispose()
4236 public T Current
4337 {
4438 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
45- get ;
46- private set ;
39+ get => array [ index ] ;
4740 }
4841 }
4942}
You can’t perform that action at this time.
0 commit comments