Skip to content

Commit 1514c0f

Browse files
committed
Optimise mod comparison function for most common case
1 parent a93c775 commit 1514c0f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,17 @@ private static bool checkIsUserHigh(IEnumerable<SoloScore> userScores, SoloScore
200200

201201
static bool compareMods(SoloScore a, SoloScore b)
202202
{
203-
// Compare non-ordered mods, ignoring any settings applied.
204-
var aMods = new HashSet<string>(a.ScoreData.Mods.Select(m => m.Acronym));
205-
var bMods = new HashSet<string>(b.ScoreData.Mods.Select(m => m.Acronym));
203+
var aMods = a.ScoreData.Mods;
204+
var bMods = b.ScoreData.Mods;
206205

207-
return aMods.SetEquals(bMods);
206+
if (aMods.Length == 0 && bMods.Length == 0)
207+
return true;
208+
209+
if (aMods.Length != bMods.Length)
210+
return false;
211+
212+
HashSet<string> bAcronyms = new HashSet<string>(bMods.Select(m => m.Acronym));
213+
return aMods.All(m => bAcronyms.Contains(m.Acronym));
208214
}
209215
}
210216
}

0 commit comments

Comments
 (0)