Skip to content

Commit c3cbaa0

Browse files
committed
Shortcut common case of single score to avoid individual check overheads
1 parent c5db2d2 commit c3cbaa0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

osu.Server.Queues.ScoreStatisticsProcessor/Commands/Maintenance/MarkNonPreservedScoresCommand.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,15 @@ private static bool checkIsUserHigh(IEnumerable<SoloScore> userScores, SoloScore
158158

159159
Debug.Assert(scores.Any());
160160

161-
preservedAlternatives = new HashSet<SoloScore>();
161+
// shortcut for case of single score match
162+
if (scores.Single() is SoloScore single)
163+
{
164+
Debug.Assert(single.beatmap_id == candidate.beatmap_id);
165+
preservedAlternatives = new HashSet<SoloScore> { single };
166+
return true;
167+
}
168+
169+
preservedAlternatives = new HashSet<SoloScore>(4);
162170

163171
// TODO: this can likely be optimised (to not recalculate every score, in the case there's many candidates per beatmap).
164172
if (scores.MaxBy(s => s.pp) is SoloScore maxPPScore)

0 commit comments

Comments
 (0)