Firmware Manager: replace unnecessary gotos

This commit is contained in:
RetroEdit 2020-09-28 15:33:59 +00:00
parent d3f1d0f6ac
commit 8449f9fcb8
No known key found for this signature in database
GPG Key ID: CE9E2A36E1EFA76F
1 changed files with 7 additions and 18 deletions

View File

@ -41,27 +41,18 @@ namespace BizHawk.Client.Common
public string FirmwareId { get; set; } public string FirmwareId { get; set; }
} }
// purpose of forbidScan: sometimes this is called from a loop in Scan(). we don't want to repeatedly DoScanAndResolve in that case, its already been done.
public ResolutionInfo Resolve(PathEntryCollection pathEntries, IDictionary<string, string> userSpecifications, FirmwareDatabase.FirmwareRecord record, bool forbidScan = false) public ResolutionInfo Resolve(PathEntryCollection pathEntries, IDictionary<string, string> userSpecifications, FirmwareDatabase.FirmwareRecord record, bool forbidScan = false)
{ {
// purpose of forbidScan: sometimes this is called from a loop in Scan(). we don't want to repeatedly DoScanAndResolve in that case, its already been done.
bool first = true;
RETRY:
_resolutionDictionary.TryGetValue(record, out var resolved); _resolutionDictionary.TryGetValue(record, out var resolved);
// couldn't find it! do a scan and resolve to try harder // couldn't find it! do a scan and resolve to try harder
// NOTE: this could result in bad performance in some cases if the scanning happens repeatedly.. // NOTE: this could result in bad performance in some cases if the scanning happens repeatedly...
if (resolved == null && first) if (resolved == null && !forbidScan)
{ {
if (!forbidScan) DoScanAndResolve(pathEntries, userSpecifications);
{ _resolutionDictionary.TryGetValue(record, out resolved);
DoScanAndResolve(pathEntries, userSpecifications);
}
first = false;
goto RETRY;
} }
return resolved; return resolved;
} }
@ -207,11 +198,9 @@ namespace BizHawk.Client.Common
Size = fo.Size Size = fo.Size
}; };
_resolutionDictionary[fr] = ri; _resolutionDictionary[fr] = ri;
goto DONE_FIRMWARE; break;
} }
} }
DONE_FIRMWARE: ;
} }
// apply user overrides // apply user overrides