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 1/2] 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;
From cb354685ca323f4e429e60617077ed5a5175ee3d Mon Sep 17 00:00:00 2001
From: Aki <75532970+AkiSakurai@users.noreply.github.com>
Date: Sun, 16 Jul 2023 10:21:32 +0800
Subject: [PATCH 2/2] simplify code
---
osu.Game/Scoring/ScoreInfoExtensions.cs | 8 --------
osu.Game/Screens/Select/Carousel/TopLocalRank.cs | 4 ++--
2 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/osu.Game/Scoring/ScoreInfoExtensions.cs b/osu.Game/Scoring/ScoreInfoExtensions.cs
index 63cc077cde..6e57a9fd0b 100644
--- a/osu.Game/Scoring/ScoreInfoExtensions.cs
+++ b/osu.Game/Scoring/ScoreInfoExtensions.cs
@@ -32,13 +32,5 @@ 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 fe2d79b080..da9661f702 100644
--- a/osu.Game/Screens/Select/Carousel/TopLocalRank.cs
+++ b/osu.Game/Screens/Select/Carousel/TopLocalRank.cs
@@ -2,6 +2,7 @@
// 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;
@@ -74,8 +75,7 @@ namespace osu.Game.Screens.Select.Carousel
if (changes?.HasCollectionChanges() == false)
return;
- ScoreInfo? topScore = sender.MaxByTopScore();
-
+ ScoreInfo? topScore = sender.MaxBy(info => (info.TotalScore, -info.Date.UtcDateTime.Ticks));
updateable.Rank = topScore?.Rank;
updateable.Alpha = topScore != null ? 1 : 0;
}