1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:17:26 +08:00

Use ctor in a place that looks visually weird

I read through this thinking "why doesn't Previous get assigned to
currentEncoding here? But it's because the initializer runs right after
the ctor and before the "method" returns. So really there's 3 operations
running on one line here - ctor, init, and assignment.
This commit is contained in:
Dan Balasescu 2022-08-15 21:30:40 +09:00
parent 502e31dd37
commit 94c6beeaf7
3 changed files with 9 additions and 7 deletions

View File

@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour.Data
/// <summary>
/// <see cref="MonoEncoding"/>s that are grouped together within this <see cref="ColourEncoding"/>.
/// </summary>
public List<MonoEncoding> Payload { get; private set; } = new List<MonoEncoding>();
public readonly List<MonoEncoding> Payload = new List<MonoEncoding>();
/// <summary>
/// The parent <see cref="CoupledColourEncoding"/> that contains this <see cref="ColourEncoding"/>

View File

@ -20,12 +20,12 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour.Data
/// <summary>
/// The <see cref="ColourEncoding"/>s that are grouped together within this <see cref="CoupledColourEncoding"/>.
/// </summary>
public List<ColourEncoding> Payload = new List<ColourEncoding>();
public readonly List<ColourEncoding> Payload = new List<ColourEncoding>();
/// <summary>
/// The previous <see cref="CoupledColourEncoding"/>. This is used to determine the repetition interval.
/// </summary>
public CoupledColourEncoding? Previous = null;
public readonly CoupledColourEncoding? Previous;
/// <summary>
/// How many <see cref="CoupledColourEncoding"/> between the current and previous identical <see cref="CoupledColourEncoding"/>.
@ -33,6 +33,11 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour.Data
/// </summary>
public int RepetitionInterval { get; private set; } = max_repetition_interval + 1;
public CoupledColourEncoding(CoupledColourEncoding? previous)
{
Previous = previous;
}
/// <summary>
/// Returns true if other is considered a repetition of this encoding. This is true if other's first two payloads
/// have identical mono lengths.

View File

@ -118,10 +118,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Colour
for (int i = 0; i < data.Count; i++)
{
// Start a new CoupledColourEncoding. ColourEncodings that should be grouped together will be handled later within this loop.
currentEncoding = new CoupledColourEncoding
{
Previous = currentEncoding
};
currentEncoding = new CoupledColourEncoding(currentEncoding);
// Determine if future ColourEncodings should be grouped.
bool isCoupled = i < data.Count - 2 && data[i].IsRepetitionOf(data[i + 2]);