1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 16:07:24 +08:00

Compute the top local rank directly without an expensive detach call

This commit is contained in:
Aki 2023-07-15 22:12:48 +08:00
parent cdbb6f90be
commit 309c852222
No known key found for this signature in database
GPG Key ID: 71EB4ADB554E1DCC
2 changed files with 9 additions and 2 deletions

View File

@ -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));
}
}

View File

@ -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;