mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 15:43:22 +08:00
Avoid sorting items when already in the correct sort order
This commit is contained in:
parent
7fda38d0b0
commit
27e778ae09
@ -86,16 +86,20 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
items.ForEach(c => c.Filter(criteria));
|
||||
|
||||
criteriaComparer = Comparer<CarouselItem>.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<CarouselItem>.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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user