Offload database query to task

Allows song select to load a touch faster, in theory.
This commit is contained in:
Dean Herbert 2018-05-30 16:15:00 +09:00
parent e8cc3294d7
commit a28e71995d
2 changed files with 8 additions and 9 deletions

View File

@ -241,7 +241,13 @@ public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap
/// Returns a list of all usable <see cref="BeatmapSetInfo"/>s.
/// </summary>
/// <returns>A list of available <see cref="BeatmapSetInfo"/>.</returns>
public List<BeatmapSetInfo> GetAllUsableBeatmapSets() => beatmaps.ConsumableItems.Where(s => !s.DeletePending && !s.Protected).ToList();
public List<BeatmapSetInfo> GetAllUsableBeatmapSets() => GetAllUsableBeatmapSetsEnumerable().ToList();
/// <summary>
/// Returns a list of all usable <see cref="BeatmapSetInfo"/>s.
/// </summary>
/// <returns>A list of available <see cref="BeatmapSetInfo"/>.</returns>
public IQueryable<BeatmapSetInfo> GetAllUsableBeatmapSetsEnumerable() => beatmaps.ConsumableItems.Where(s => !s.DeletePending && !s.Protected);
/// <summary>
/// Perform a lookup query on available <see cref="BeatmapSetInfo"/>s.

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Threading;
using OpenTK;
using OpenTK.Input;
using osu.Framework.Allocation;
@ -63,8 +62,6 @@ public abstract class SongSelect : OsuScreen
private SampleChannel sampleChangeDifficulty;
private SampleChannel sampleChangeBeatmap;
private CancellationTokenSource initialAddSetsTask;
private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(parent);
@ -207,9 +204,7 @@ private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dia
sampleChangeDifficulty = audio.Sample.Get(@"SongSelect/select-difficulty");
sampleChangeBeatmap = audio.Sample.Get(@"SongSelect/select-expand");
initialAddSetsTask = new CancellationTokenSource();
Carousel.BeatmapSets = this.beatmaps.GetAllUsableBeatmapSets();
Carousel.BeatmapSets = this.beatmaps.GetAllUsableBeatmapSetsEnumerable();
Beatmap.DisabledChanged += disabled => Carousel.AllowSelection = !disabled;
Beatmap.TriggerChange();
@ -417,8 +412,6 @@ protected override void Dispose(bool isDisposing)
beatmaps.BeatmapHidden -= onBeatmapHidden;
beatmaps.BeatmapRestored -= onBeatmapRestored;
}
initialAddSetsTask?.Cancel();
}
/// <summary>