Remove eager check of Current

The SaveUtil's ienumerable can be of different collection types, and the result is usually is a collection with >0 count
I think I was initially confused (years and years ago) about "MoveNext" if it discarded the first result.

Remove the eager check of the enumerator's current value because it hasn't yet been moved from the uninitialized state.

Closes #3871

Dispose of the enumerator on the early empty return, since the later async code will dispose once all have been iterated.
This commit is contained in:
Kurt 2023-04-26 21:41:38 -07:00
parent d4d353c087
commit 583a036d65

View file

@ -262,10 +262,10 @@ public partial class SAV_FolderList : Form
var list = new SaveList<SavePreview>();
var enumerator = saves.GetEnumerator();
while (enumerator.Current == null)
if (!enumerator.MoveNext())
{
if (!enumerator.MoveNext())
return list;
enumerator.Dispose();
return list;
}
var first = enumerator.Current;