From 309c8522227d63d647847ad0cf90ccf1f5ffd6eb Mon Sep 17 00:00:00 2001
From: Aki <75532970+AkiSakurai@users.noreply.github.com>
Date: Sat, 15 Jul 2023 22:12:48 +0800
Subject: [PATCH] Compute the top local rank directly without an expensive
detach call
---
osu.Game/Scoring/ScoreInfoExtensions.cs | 8 ++++++++
osu.Game/Screens/Select/Carousel/TopLocalRank.cs | 3 +--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/osu.Game/Scoring/ScoreInfoExtensions.cs b/osu.Game/Scoring/ScoreInfoExtensions.cs
index 6e57a9fd0b..63cc077cde 100644
--- a/osu.Game/Scoring/ScoreInfoExtensions.cs
+++ b/osu.Game/Scoring/ScoreInfoExtensions.cs
@@ -32,5 +32,13 @@ namespace osu.Game.Scoring
/// The to compute the maximum achievable combo for.
/// The maximum achievable combo.
public static int GetMaximumAchievableCombo(this ScoreInfo score) => score.MaximumStatistics.Where(kvp => kvp.Key.AffectsCombo()).Sum(kvp => kvp.Value);
+
+ ///
+ /// Retrieves the with the maximum total score.
+ ///
+ /// An array of s to retrieve the scoreInfo with maximum total score.
+ /// The instance with the maximum total score.
+ public static ScoreInfo? MaxByTopScore(this IEnumerable scores)
+ => scores.MaxBy(info => (info.TotalScore, -info.OnlineID, -info.Date.UtcDateTime.Ticks));
}
}
diff --git a/osu.Game/Screens/Select/Carousel/TopLocalRank.cs b/osu.Game/Screens/Select/Carousel/TopLocalRank.cs
index c17de77619..fe2d79b080 100644
--- a/osu.Game/Screens/Select/Carousel/TopLocalRank.cs
+++ b/osu.Game/Screens/Select/Carousel/TopLocalRank.cs
@@ -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;