Skip to content

Commit

Permalink
Remove redundant null initialisation and apply nullability
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Nov 14, 2024
1 parent 7670a81 commit d37c1bb
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions osu.Game/Beatmaps/StarDifficulty.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using JetBrains.Annotations;
using osu.Framework.Utils;
using osu.Game.Rulesets.Difficulty;

Expand All @@ -25,20 +22,18 @@ public readonly struct StarDifficulty
/// The difficulty attributes computed for the given beatmap.
/// Might not be available if the star difficulty is associated with a beatmap that's not locally available.
/// </summary>
[CanBeNull]
public readonly DifficultyAttributes DifficultyAttributes;
public readonly DifficultyAttributes? DifficultyAttributes;

/// <summary>
/// The performance attributes computed for a perfect score on the given beatmap.
/// Might not be available if the star difficulty is associated with a beatmap that's not locally available.
/// </summary>
[CanBeNull]
public readonly PerformanceAttributes PerformanceAttributes;
public readonly PerformanceAttributes? PerformanceAttributes;

/// <summary>
/// Creates a <see cref="StarDifficulty"/> structure.
/// </summary>
public StarDifficulty([NotNull] DifficultyAttributes difficulty, [NotNull] PerformanceAttributes performance)
public StarDifficulty(DifficultyAttributes difficulty, PerformanceAttributes performance)
{
Stars = double.IsFinite(difficulty.StarRating) ? difficulty.StarRating : 0;
MaxCombo = difficulty.MaxCombo;
Expand All @@ -55,7 +50,6 @@ public StarDifficulty(double starDifficulty, int maxCombo)
{
Stars = double.IsFinite(starDifficulty) ? starDifficulty : 0;
MaxCombo = maxCombo;
DifficultyAttributes = null;
}

public DifficultyRating DifficultyRating => GetDifficultyRating(Stars);
Expand Down

0 comments on commit d37c1bb

Please sign in to comment.