Skip to content

Commit a3d3e96

Browse files
committed
Refactor equality check in MDS_Format.MountBlobs
1 parent ed497a7 commit a3d3e96

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ public static LoadResults LoadMDSPath(string path)
635635
/// <exception cref="MDSParseException">path reference no longer points to file</exception>
636636
private static Dictionary<int, IBlob> MountBlobs(AFile mdsf, Disc disc)
637637
{
638+
Debug.Assert(disc.DisposableResources.Count is 0, "no other method should be adding to DisposableResources");
638639
var BlobIndex = new Dictionary<int, IBlob>();
639640

640641
var count = 0;
@@ -646,17 +647,10 @@ private static Dictionary<int, IBlob> MountBlobs(AFile mdsf, Disc disc)
646647
throw new MDSParseException($"Malformed MDS format: nonexistent image file: {file}");
647648

648649
//mount the file
649-
var mdfBlob = new Blob_RawFile { PhysicalPath = file };
650-
651-
var dupe = false;
652-
foreach (var re in disc.DisposableResources)
653-
{
654-
if (re.ToString() == mdfBlob.ToString())
655-
dupe = true;
656-
}
657-
658-
if (!dupe)
650+
if (!disc.DisposableResources.Cast<Blob_RawFile>()
651+
.Select(static re => re.PhysicalPath).Contains(file))
659652
{
653+
Blob_RawFile mdfBlob = new() { PhysicalPath = file };
660654
// wrap in zeropadadapter
661655
disc.DisposableResources.Add(mdfBlob);
662656
BlobIndex[count++] = mdfBlob;

0 commit comments

Comments
 (0)