1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 08:52:55 +08:00

Use a more readable code for calculating length

This commit is contained in:
iiSaLMaN 2019-07-09 17:22:21 +03:00
parent 38bc652bf2
commit f3329f4d79

View File

@ -315,10 +315,15 @@ namespace osu.Game.Beatmaps
private double calculateLength(IBeatmap b)
{
var lastObject = b.HitObjects.LastOrDefault();
var endTime = (lastObject as IHasEndTime)?.EndTime ?? lastObject?.StartTime ?? 0;
if (!b.HitObjects.Any())
return 0;
return endTime - b.HitObjects.FirstOrDefault()?.StartTime ?? 0;
var lastObject = b.HitObjects.Last();
double endTime = (lastObject as IHasEndTime)?.EndTime ?? lastObject.StartTime;
double startTime = b.HitObjects.First().StartTime;
return endTime - startTime;
}
/// <summary>