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

@ -76,6 +76,14 @@ namespace osu.Game.Database
{
applyCommonConfiguration(c);
c.CreateMap<BeatmapSetInfo, BeatmapSetInfo>()
.MaxDepth(2)
.AfterMap((s, d) =>
{
foreach (var beatmap in d.Beatmaps)
beatmap.BeatmapSet = d;
});
// This can be further optimised to reduce cyclic retrievals, similar to the optimised set mapper below.
// Only hasn't been done yet as we detach at the point of BeatmapInfo less often.
c.CreateMap<BeatmapInfo, BeatmapInfo>()
@ -100,6 +108,15 @@ namespace osu.Game.Database
{
applyCommonConfiguration(c);
c.CreateMap<BeatmapSetInfo, BeatmapSetInfo>()
.MaxDepth(2)
.ForMember(b => b.Files, cc => cc.Ignore())
.AfterMap((s, d) =>
{
foreach (var beatmap in d.Beatmaps)
beatmap.BeatmapSet = d;
});
c.CreateMap<BeatmapInfo, BeatmapInfo>()
.MaxDepth(1)
.ForMember(b => b.BeatmapSet, cc => cc.Ignore());
@ -131,13 +148,6 @@ namespace osu.Game.Database
c.CreateMap<RealmUser, RealmUser>();
c.CreateMap<RealmFile, RealmFile>();
c.CreateMap<RealmNamedFileUsage, RealmNamedFileUsage>();
c.CreateMap<BeatmapSetInfo, BeatmapSetInfo>()
.MaxDepth(2)
.AfterMap((s, d) =>
{
foreach (var beatmap in d.Beatmaps)
beatmap.BeatmapSet = d;
});
}
/// <summary>