Use early return for if-pattern-matching.

This commit is contained in:
Huo Yaoyuan
2019-11-22 00:02:40 +08:00
parent 20f01ff3e9
commit 4cd7d67fe4
5 changed files with 47 additions and 51 deletions

View File

@ -474,15 +474,13 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
/// <returns></returns>
private IList<HitSampleInfo> sampleInfoListAt(double time)
{
if (HitObject is IHasCurve curveData)
{
double segmentTime = (EndTime - HitObject.StartTime) / spanCount;
if (!(HitObject is IHasCurve curveData))
return HitObject.Samples;
int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime);
return curveData.NodeSamples[index];
}
double segmentTime = (EndTime - HitObject.StartTime) / spanCount;
return HitObject.Samples;
int index = (int)(segmentTime == 0 ? 0 : (time - HitObject.StartTime) / segmentTime);
return curveData.NodeSamples[index];
}
/// <summary>