mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 14:17:26 +08:00
Simplify implementation of CalculatePerformanceAsync
This commit is contained in:
parent
7117fd0fba
commit
d4ba9d2682
@ -26,19 +26,14 @@ namespace osu.Game.Scoring
|
||||
/// <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
Block a user