Skip to content

Commit e5e56a4

Browse files
committed
Refactor equality check in MDS_Format.MountBlobs
1 parent 6184afd commit e5e56a4

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

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

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@ public static LoadResults LoadMDSPath(string path)
657657
/// <exception cref="MDSParseException">path reference no longer points to file</exception>
658658
private static Dictionary<int, IBlob> MountBlobs(AFile mdsf, Disc disc)
659659
{
660+
Debug.Assert(disc.DisposableResources.Count is 0, "no other method should be adding to DisposableResources");
660661
var BlobIndex = new Dictionary<int, IBlob>();
661662

662663
var count = 0;
@@ -667,18 +668,11 @@ private static Dictionary<int, IBlob> MountBlobs(AFile mdsf, Disc disc)
667668
if (!File.Exists(file))
668669
throw new MDSParseException($"Malformed MDS format: nonexistent image file: {file}");
669670

670-
//mount the file
671-
var mdfBlob = new Blob_RawFile { PhysicalPath = file };
672-
673-
var dupe = false;
674-
foreach (var re in disc.DisposableResources)
675-
{
676-
if (re.ToString() == mdfBlob.ToString())
677-
dupe = true;
678-
}
679-
680-
if (!dupe)
671+
//mount the file
672+
if (!disc.DisposableResources.Cast<Blob_RawFile>()
673+
.Select(static re => re.PhysicalPath).Contains(file))
681674
{
675+
Blob_RawFile mdfBlob = new() { PhysicalPath = file };
682676
// wrap in zeropadadapter
683677
disc.DisposableResources.Add(mdfBlob);
684678
BlobIndex[count++] = mdfBlob;

0 commit comments

Comments
 (0)