Avoid file retrieval overhead when detaching BeatmapSetInfo

It seems that no usages of `BeatmapSetInfo` detaches require files - a
`WorkingBeatmap` is always obtained before doing further lookups.

Therefore we can omit this include unless the detaching object is a
`BeatmapInfo`. A refetch is performed when retrieving a
`WorkingBeatmap` to complete the equation.
This commit is contained in:
Dean Herbert
2022-01-19 00:49:16 +09:00
parent f2b151023e
commit 60b80c88b6
2 changed files with 34 additions and 8 deletions

View File

@ -299,7 +299,23 @@ namespace osu.Game.Beatmaps
#region Implementation of IWorkingBeatmapCache
public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo? importedBeatmap) => workingBeatmapCache.GetWorkingBeatmap(importedBeatmap);
public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo? importedBeatmap)
{
// Detached sets don't come with files.
// If we seem to be missing files, now is a good time to re-fetch.
if (importedBeatmap?.BeatmapSet?.Files.Count == 0)
{
using (var realm = contextFactory.CreateContext())
{
var refetch = realm.Find<BeatmapInfo>(importedBeatmap.ID)?.Detach();
if (refetch != null)
importedBeatmap = refetch;
}
}
return workingBeatmapCache.GetWorkingBeatmap(importedBeatmap);
}
public WorkingBeatmap GetWorkingBeatmap(ILive<BeatmapInfo>? importedBeatmap)
{