diff --git a/osu.Game/Screens/Select/Carousel/CarouselGroup.cs b/osu.Game/Screens/Select/Carousel/CarouselGroup.cs index 9302578038..c353ee98ae 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselGroup.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselGroup.cs @@ -86,16 +86,20 @@ namespace osu.Game.Screens.Select.Carousel items.ForEach(c => c.Filter(criteria)); - criteriaComparer = Comparer.Create((x, y) => + // Sorting is expensive, so only perform if it's actually changed. + if (lastCriteria?.Sort != criteria.Sort) { - int comparison = x.CompareTo(criteria, y); - if (comparison != 0) - return comparison; + criteriaComparer = Comparer.Create((x, y) => + { + int comparison = x.CompareTo(criteria, y); + if (comparison != 0) + return comparison; - return x.ItemID.CompareTo(y.ItemID); - }); + return x.ItemID.CompareTo(y.ItemID); + }); - items.Sort(criteriaComparer); + items.Sort(criteriaComparer); + } lastCriteria = criteria; }