Skip to content

Commit cb082da

Browse files
authored
Merge pull request #33514 from peppy/fix-potential-sets-changed-overhead
Ensure `beatmapSetsChanged` code doesn't run during gameplay
2 parents 4fef1e1 + f183496 commit cb082da

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

osu.Game/Screens/SelectV2/BeatmapCarousel.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,15 @@ protected override void LoadComplete()
119119

120120
#region Beatmap source hookup
121121

122-
private void beatmapSetsChanged(object? beatmaps, NotifyCollectionChangedEventArgs changed)
122+
private void beatmapSetsChanged(object? beatmaps, NotifyCollectionChangedEventArgs changed) => Schedule(() =>
123123
{
124+
// This callback is scheduled to ensure there's no added overhead during gameplay.
125+
// If this ever becomes an issue, it's important to note that the actual carousel filtering is already
126+
// implemented in a way it will only run when at song select.
127+
//
128+
// The overhead we are avoiding here is that of this method directly – things like Items.IndexOf calls
129+
// that can be slow for very large beatmap libraries. There are definitely ways to optimise this further.
130+
124131
// TODO: moving management of BeatmapInfo tracking to BeatmapStore might be something we want to consider.
125132
// right now we are managing this locally which is a bit of added overhead.
126133
IEnumerable<BeatmapSetInfo>? newItems = changed.NewItems?.Cast<BeatmapSetInfo>();
@@ -191,7 +198,7 @@ private void beatmapSetsChanged(object? beatmaps, NotifyCollectionChangedEventAr
191198
Items.Clear();
192199
break;
193200
}
194-
}
201+
});
195202

196203
#endregion
197204

0 commit comments

Comments
 (0)