mirror of https://github.com/ppy/osu
Simplify implementation of CalculatePerformanceAsync
This commit is contained in:
parent
7117fd0fba
commit
d4ba9d2682
|
@ -26,19 +26,14 @@ public class ScorePerformanceManager : Component
|
|||
/// <param name="token">An optional <see cref="CancellationToken"/> to cancel the operation.</param>
|
||||
public async Task<double?> CalculatePerformanceAsync([NotNull] ScoreInfo score, CancellationToken token = default)
|
||||
{
|
||||
if (tryGetExisting(score, out var perf, out var lookupKey))
|
||||
return perf;
|
||||
var lookupKey = new PerformanceCacheLookup(score);
|
||||
|
||||
if (performanceCache.TryGetValue(lookupKey, out double performance))
|
||||
return performance;
|
||||
|
||||
return await computePerformanceAsync(score, lookupKey, token);
|
||||
}
|
||||
|
||||
private bool tryGetExisting(ScoreInfo score, out double performance, out PerformanceCacheLookup lookupKey)
|
||||
{
|
||||
lookupKey = new PerformanceCacheLookup(score);
|
||||
|
||||
return performanceCache.TryGetValue(lookupKey, out performance);
|
||||
}
|
||||
|
||||
private async Task<double?> computePerformanceAsync(ScoreInfo score, PerformanceCacheLookup lookupKey, CancellationToken token = default)
|
||||
{
|
||||
var attributes = await difficultyManager.GetDifficultyAsync(score.Beatmap, score.Ruleset, score.Mods, token);
|
||||
|
|
Loading…
Reference in New Issue