Better enumerator code

This commit is contained in:
Haselnussbomber 2025-12-16 09:48:59 +01:00
parent 2e7c48316f
commit 1c1b60efee
No known key found for this signature in database
GPG key ID: BB905BB49E7295D1
6 changed files with 46 additions and 34 deletions

View file

@ -99,7 +99,7 @@ internal sealed partial class AetheryteList
private struct Enumerator(AetheryteList aetheryteList) : IEnumerator<IAetheryteEntry>
{
private int index = 0;
private int index = -1;
public IAetheryteEntry Current { get; private set; }
@ -107,15 +107,19 @@ internal sealed partial class AetheryteList
public bool MoveNext()
{
if (this.index == aetheryteList.Length) return false;
this.Current = aetheryteList[this.index];
this.index++;
return true;
if (++this.index < aetheryteList.Length)
{
this.Current = aetheryteList[this.index];
return true;
}
this.Current = default;
return false;
}
public void Reset()
{
this.index = 0;
this.index = -1;
}
public void Dispose()