mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 16:03:01 +08:00
Eliminate unnecessary loop
This commit is contained in:
parent
cd2280b5bf
commit
9fb494d5d3
@ -80,6 +80,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private double repetitionPenalties()
|
private double repetitionPenalties()
|
||||||
{
|
{
|
||||||
|
const int l = 2;
|
||||||
double penalty = 1.0;
|
double penalty = 1.0;
|
||||||
|
|
||||||
monoHistory.Add(currentMonoLength);
|
monoHistory.Add(currentMonoLength);
|
||||||
@ -87,27 +88,24 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills
|
|||||||
if (monoHistory.Count > mono_history_max_length)
|
if (monoHistory.Count > mono_history_max_length)
|
||||||
monoHistory.RemoveAt(0);
|
monoHistory.RemoveAt(0);
|
||||||
|
|
||||||
for (int l = 2; l <= mono_history_max_length / 2; l++)
|
for (int start = monoHistory.Count - l - 1; start >= 0; start--)
|
||||||
{
|
{
|
||||||
for (int start = monoHistory.Count - l - 1; start >= 0; start--)
|
bool samePattern = true;
|
||||||
|
|
||||||
|
for (int i = 0; i < l; i++)
|
||||||
{
|
{
|
||||||
bool samePattern = true;
|
if (monoHistory[start + i] != monoHistory[monoHistory.Count - l + i])
|
||||||
|
|
||||||
for (int i = 0; i < l; i++)
|
|
||||||
{
|
{
|
||||||
if (monoHistory[start + i] != monoHistory[monoHistory.Count - l + i])
|
samePattern = false;
|
||||||
{
|
|
||||||
samePattern = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (samePattern) // Repetition found!
|
if (samePattern) // Repetition found!
|
||||||
{
|
{
|
||||||
int notesSince = 0;
|
int notesSince = 0;
|
||||||
for (int i = start; i < monoHistory.Count; i++) notesSince += monoHistory[i];
|
for (int i = start; i < monoHistory.Count; i++) notesSince += monoHistory[i];
|
||||||
penalty *= repetitionPenalty(notesSince);
|
penalty *= repetitionPenalty(notesSince);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user