diff --git a/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs b/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs
index 6d2e938fb7..d2b71b1d5e 100644
--- a/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs
+++ b/osu.Game/Screens/Select/Carousel/CarouselBeatmapSet.cs
@@ -127,12 +127,40 @@ namespace osu.Game.Screens.Select.Carousel
///
/// All beatmaps which are not filtered and valid for display.
///
- protected IEnumerable ValidBeatmaps => Beatmaps.Where(b => !b.Filtered.Value || b.State.Value == CarouselItemState.Selected).Select(b => b.BeatmapInfo);
+ protected IEnumerable ValidBeatmaps
+ {
+ get
+ {
+ foreach (var item in Items) // iterating over Items directly to not allocate 2 enumerators
+ {
+ if (item is CarouselBeatmap b && (!b.Filtered.Value || b.State.Value == CarouselItemState.Selected))
+ yield return b.BeatmapInfo;
+ }
+ }
+ }
+
+ ///
+ /// Whether there are available beatmaps which are not filtered and valid for display.
+ /// Cheaper alternative to .Any()
+ ///
+ public bool HasValidBeatmaps
+ {
+ get
+ {
+ foreach (var item in Items) // iterating over Items directly to not allocate 2 enumerators
+ {
+ if (item is CarouselBeatmap b && (!b.Filtered.Value || b.State.Value == CarouselItemState.Selected))
+ return true;
+ }
+
+ return false;
+ }
+ }
private int compareUsingAggregateMax(CarouselBeatmapSet other, Func func)
{
- bool ourBeatmaps = ValidBeatmaps.Any();
- bool otherBeatmaps = other.ValidBeatmaps.Any();
+ bool ourBeatmaps = HasValidBeatmaps;
+ bool otherBeatmaps = other.HasValidBeatmaps;
if (!ourBeatmaps && !otherBeatmaps) return 0;
if (!ourBeatmaps) return -1;