mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 11:12:59 +08:00
Avoid LINQ overhead in PatternGenerator.isValid
This commit is contained in:
parent
16e60eed56
commit
03291e3897
@ -149,7 +149,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
|||||||
{
|
{
|
||||||
lowerBound ??= RandomStart;
|
lowerBound ??= RandomStart;
|
||||||
upperBound ??= TotalColumns;
|
upperBound ??= TotalColumns;
|
||||||
nextColumn ??= (_ => GetRandomColumn(lowerBound, upperBound));
|
nextColumn ??= _ => GetRandomColumn(lowerBound, upperBound);
|
||||||
|
|
||||||
// Check for the initial column
|
// Check for the initial column
|
||||||
if (isValid(initialColumn))
|
if (isValid(initialColumn))
|
||||||
@ -176,7 +176,19 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy
|
|||||||
|
|
||||||
return initialColumn;
|
return initialColumn;
|
||||||
|
|
||||||
bool isValid(int column) => validation?.Invoke(column) != false && !patterns.Any(p => p.ColumnHasObject(column));
|
bool isValid(int column)
|
||||||
|
{
|
||||||
|
if (validation?.Invoke(column) == false)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
foreach (var p in patterns)
|
||||||
|
{
|
||||||
|
if (p.ColumnHasObject(column))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user