Refactor equality check in `MDS_Format.MountBlobs`

This commit is contained in:
YoshiRulz 2025-02-15 08:45:19 +10:00
parent 6184afddc9
commit e5e56a478f
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 5 additions and 11 deletions

View File

@ -657,6 +657,7 @@ namespace BizHawk.Emulation.DiscSystem
/// <exception cref="MDSParseException">path reference no longer points to file</exception>
private static Dictionary<int, IBlob> MountBlobs(AFile mdsf, Disc disc)
{
Debug.Assert(disc.DisposableResources.Count is 0, "no other method should be adding to DisposableResources");
var BlobIndex = new Dictionary<int, IBlob>();
var count = 0;
@ -667,18 +668,11 @@ namespace BizHawk.Emulation.DiscSystem
if (!File.Exists(file))
throw new MDSParseException($"Malformed MDS format: nonexistent image file: {file}");
//mount the file
var mdfBlob = new Blob_RawFile { PhysicalPath = file };
var dupe = false;
foreach (var re in disc.DisposableResources)
{
if (re.ToString() == mdfBlob.ToString())
dupe = true;
}
if (!dupe)
//mount the file
if (!disc.DisposableResources.Cast<Blob_RawFile>()
.Select(static re => re.PhysicalPath).Contains(file))
{
Blob_RawFile mdfBlob = new() { PhysicalPath = file };
// wrap in zeropadadapter
disc.DisposableResources.Add(mdfBlob);
BlobIndex[count++] = mdfBlob;