mirror of
https://github.com/ppy/osu
synced 2024-12-29 10:22:43 +00:00
Compute the top local rank directly without an expensive detach call
This commit is contained in:
parent
cdbb6f90be
commit
309c852222
@ -32,5 +32,13 @@ namespace osu.Game.Scoring
|
||||
/// <param name="score">The <see cref="ScoreInfo"/> to compute the maximum achievable combo for.</param>
|
||||
/// <returns>The maximum achievable combo.</returns>
|
||||
public static int GetMaximumAchievableCombo(this ScoreInfo score) => score.MaximumStatistics.Where(kvp => kvp.Key.AffectsCombo()).Sum(kvp => kvp.Value);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the <see cref="ScoreInfo"/> with the maximum total score.
|
||||
/// </summary>
|
||||
/// <param name="scores">An array of <see cref="ScoreInfo"/>s to retrieve the scoreInfo with maximum total score.</param>
|
||||
/// <returns>The <see cref="ScoreInfo"/> instance with the maximum total score.</returns>
|
||||
public static ScoreInfo? MaxByTopScore(this IEnumerable<ScoreInfo> scores)
|
||||
=> scores.MaxBy(info => (info.TotalScore, -info.OnlineID, -info.Date.UtcDateTime.Ticks));
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -75,7 +74,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
if (changes?.HasCollectionChanges() == false)
|
||||
return;
|
||||
|
||||
ScoreInfo? topScore = sender.Detach().OrderByTotalScore().FirstOrDefault();
|
||||
ScoreInfo? topScore = sender.MaxByTopScore();
|
||||
|
||||
updateable.Rank = topScore?.Rank;
|
||||
updateable.Alpha = topScore != null ? 1 : 0;
|
||||
|
Loading…
Reference in New Issue
Block a user