mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 01:32:55 +08:00
Reduce HitSampleInfo constants allocations
This commit is contained in:
parent
1ca28d74a3
commit
e8dc09f5bc
@ -230,7 +230,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
|
||||
// If samples aren't available at the exact start time of the object,
|
||||
// use samples (without additions) in the closest original hit object instead
|
||||
obj.Samples = samples ?? getClosestHitObject(originalHitObjects, obj.StartTime).Samples.Where(s => !HitSampleInfo.AllAdditions.Contains(s.Name)).ToList();
|
||||
obj.Samples = samples ?? getClosestHitObject(originalHitObjects, obj.StartTime).Samples.Where(s => !HitSampleInfo.ALL_ADDITIONS.Contains(s.Name)).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,12 +33,12 @@ namespace osu.Game.Audio
|
||||
/// <summary>
|
||||
/// All valid sample addition constants.
|
||||
/// </summary>
|
||||
public static IEnumerable<string> AllAdditions => new[] { HIT_WHISTLE, HIT_FINISH, HIT_CLAP };
|
||||
public static readonly string[] ALL_ADDITIONS = new[] { HIT_WHISTLE, HIT_FINISH, HIT_CLAP };
|
||||
|
||||
/// <summary>
|
||||
/// All valid bank constants.
|
||||
/// </summary>
|
||||
public static IEnumerable<string> AllBanks => new[] { BANK_NORMAL, BANK_SOFT, BANK_DRUM };
|
||||
public static readonly string[] ALL_BANKS = new[] { BANK_NORMAL, BANK_SOFT, BANK_DRUM };
|
||||
|
||||
/// <summary>
|
||||
/// The name of the sample to load.
|
||||
|
@ -119,8 +119,8 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
string bank = parts[0];
|
||||
string sampleSet = parts[1];
|
||||
|
||||
return HitSampleInfo.AllBanks.Contains(bank)
|
||||
&& HitSampleInfo.AllAdditions.Append(HitSampleInfo.HIT_NORMAL).Any(sampleSet.StartsWith);
|
||||
return HitSampleInfo.ALL_BANKS.Contains(bank)
|
||||
&& HitSampleInfo.ALL_ADDITIONS.Append(HitSampleInfo.HIT_NORMAL).Any(sampleSet.StartsWith);
|
||||
}
|
||||
|
||||
public class IssueTemplateConsequentDelay : IssueTemplate
|
||||
|
@ -114,7 +114,7 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
++objectsWithoutHitsounds;
|
||||
}
|
||||
|
||||
private bool isHitsound(HitSampleInfo sample) => HitSampleInfo.AllAdditions.Any(sample.Name.Contains);
|
||||
private bool isHitsound(HitSampleInfo sample) => HitSampleInfo.ALL_ADDITIONS.Any(sample.Name.Contains);
|
||||
private bool isHitnormal(HitSampleInfo sample) => sample.Name.Contains(HitSampleInfo.HIT_NORMAL);
|
||||
|
||||
public abstract class IssueTemplateLongPeriod : IssueTemplate
|
||||
|
@ -79,7 +79,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// </summary>
|
||||
private void createStateBindables()
|
||||
{
|
||||
foreach (string bankName in HitSampleInfo.AllBanks.Prepend(HIT_BANK_AUTO))
|
||||
foreach (string bankName in HitSampleInfo.ALL_BANKS.Prepend(HIT_BANK_AUTO))
|
||||
{
|
||||
var bindable = new Bindable<TernaryState>
|
||||
{
|
||||
@ -143,7 +143,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
SelectionBankStates[bankName] = bindable;
|
||||
}
|
||||
|
||||
foreach (string bankName in HitSampleInfo.AllBanks.Prepend(HIT_BANK_AUTO))
|
||||
foreach (string bankName in HitSampleInfo.ALL_BANKS.Prepend(HIT_BANK_AUTO))
|
||||
{
|
||||
var bindable = new Bindable<TernaryState>
|
||||
{
|
||||
@ -216,7 +216,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
|
||||
resetTernaryStates();
|
||||
|
||||
foreach (string sampleName in HitSampleInfo.AllAdditions)
|
||||
foreach (string sampleName in HitSampleInfo.ALL_ADDITIONS)
|
||||
{
|
||||
var bindable = new Bindable<TernaryState>
|
||||
{
|
||||
|
@ -409,7 +409,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
|
||||
private void createStateBindables()
|
||||
{
|
||||
foreach (string sampleName in HitSampleInfo.AllAdditions)
|
||||
foreach (string sampleName in HitSampleInfo.ALL_ADDITIONS)
|
||||
{
|
||||
var bindable = new Bindable<TernaryState>
|
||||
{
|
||||
@ -433,7 +433,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
selectionSampleStates[sampleName] = bindable;
|
||||
}
|
||||
|
||||
banks.AddRange(HitSampleInfo.AllBanks.Prepend(EditorSelectionHandler.HIT_BANK_AUTO));
|
||||
banks.AddRange(HitSampleInfo.ALL_BANKS.Prepend(EditorSelectionHandler.HIT_BANK_AUTO));
|
||||
}
|
||||
|
||||
private void updateTernaryStates()
|
||||
|
@ -157,7 +157,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
|
||||
foreach (var sample in hitObject.Samples)
|
||||
{
|
||||
if (!HitSampleInfo.AllBanks.Contains(sample.Bank))
|
||||
if (!HitSampleInfo.ALL_BANKS.Contains(sample.Bank))
|
||||
minimumGap = Math.Max(minimumGap, absolute_minimum_gap + sample.Bank.Length * 3);
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
|
||||
foreach (var sample in hasRepeats.NodeSamples.SelectMany(s => s))
|
||||
{
|
||||
if (!HitSampleInfo.AllBanks.Contains(sample.Bank))
|
||||
if (!HitSampleInfo.ALL_BANKS.Contains(sample.Bank))
|
||||
minimumGap = Math.Max(minimumGap, absolute_minimum_gap + sample.Bank.Length * 3);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user