1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-31 05:32:57 +08:00

Reduce HitSampleInfo constants allocations

This commit is contained in:
Andrei Zavatski 2025-01-07 00:36:58 +03:00
parent 1ca28d74a3
commit e8dc09f5bc
7 changed files with 13 additions and 13 deletions

View File

@ -230,7 +230,7 @@ namespace osu.Game.Rulesets.Osu.Mods
// If samples aren't available at the exact start time of the object, // If samples aren't available at the exact start time of the object,
// use samples (without additions) in the closest original hit object instead // 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();
} }
} }

View File

@ -33,12 +33,12 @@ namespace osu.Game.Audio
/// <summary> /// <summary>
/// All valid sample addition constants. /// All valid sample addition constants.
/// </summary> /// </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> /// <summary>
/// All valid bank constants. /// All valid bank constants.
/// </summary> /// </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> /// <summary>
/// The name of the sample to load. /// The name of the sample to load.

View File

@ -119,8 +119,8 @@ namespace osu.Game.Rulesets.Edit.Checks
string bank = parts[0]; string bank = parts[0];
string sampleSet = parts[1]; string sampleSet = parts[1];
return HitSampleInfo.AllBanks.Contains(bank) return HitSampleInfo.ALL_BANKS.Contains(bank)
&& HitSampleInfo.AllAdditions.Append(HitSampleInfo.HIT_NORMAL).Any(sampleSet.StartsWith); && HitSampleInfo.ALL_ADDITIONS.Append(HitSampleInfo.HIT_NORMAL).Any(sampleSet.StartsWith);
} }
public class IssueTemplateConsequentDelay : IssueTemplate public class IssueTemplateConsequentDelay : IssueTemplate

View File

@ -114,7 +114,7 @@ namespace osu.Game.Rulesets.Edit.Checks
++objectsWithoutHitsounds; ++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); private bool isHitnormal(HitSampleInfo sample) => sample.Name.Contains(HitSampleInfo.HIT_NORMAL);
public abstract class IssueTemplateLongPeriod : IssueTemplate public abstract class IssueTemplateLongPeriod : IssueTemplate

View File

@ -79,7 +79,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// </summary> /// </summary>
private void createStateBindables() 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> var bindable = new Bindable<TernaryState>
{ {
@ -143,7 +143,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
SelectionBankStates[bankName] = bindable; 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> var bindable = new Bindable<TernaryState>
{ {
@ -216,7 +216,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
resetTernaryStates(); resetTernaryStates();
foreach (string sampleName in HitSampleInfo.AllAdditions) foreach (string sampleName in HitSampleInfo.ALL_ADDITIONS)
{ {
var bindable = new Bindable<TernaryState> var bindable = new Bindable<TernaryState>
{ {

View File

@ -409,7 +409,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
private void createStateBindables() private void createStateBindables()
{ {
foreach (string sampleName in HitSampleInfo.AllAdditions) foreach (string sampleName in HitSampleInfo.ALL_ADDITIONS)
{ {
var bindable = new Bindable<TernaryState> var bindable = new Bindable<TernaryState>
{ {
@ -433,7 +433,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
selectionSampleStates[sampleName] = bindable; 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() private void updateTernaryStates()

View File

@ -157,7 +157,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
foreach (var sample in hitObject.Samples) 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); 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)) 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); minimumGap = Math.Max(minimumGap, absolute_minimum_gap + sample.Bank.Length * 3);
} }
} }