mirror of
https://github.com/ppy/osu.git
synced 2025-01-18 08:32:54 +08:00
Merge pull request #31436 from EVAST9919/editor-alloc
Reduce allocations in the editor caused by `TimelineBlueprintContainer`
This commit is contained in:
commit
638128ba88
@ -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 = [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 = [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()
|
||||
|
@ -155,9 +155,11 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
if (hitObject.GetEndTime() < editorClock.CurrentTime - timeline.VisibleRange / 2)
|
||||
break;
|
||||
|
||||
foreach (var sample in hitObject.Samples)
|
||||
for (int i = 0; i < hitObject.Samples.Count; i++)
|
||||
{
|
||||
if (!HitSampleInfo.AllBanks.Contains(sample.Bank))
|
||||
var sample = hitObject.Samples[i];
|
||||
|
||||
if (!HitSampleInfo.ALL_BANKS.Contains(sample.Bank))
|
||||
minimumGap = Math.Max(minimumGap, absolute_minimum_gap + sample.Bank.Length * 3);
|
||||
}
|
||||
|
||||
@ -165,10 +167,17 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
smallestTimeGap = Math.Min(smallestTimeGap, hasRepeats.Duration / hasRepeats.SpanCount() / 2);
|
||||
|
||||
foreach (var sample in hasRepeats.NodeSamples.SelectMany(s => s))
|
||||
for (int i = 0; i < hasRepeats.NodeSamples.Count; i++)
|
||||
{
|
||||
if (!HitSampleInfo.AllBanks.Contains(sample.Bank))
|
||||
minimumGap = Math.Max(minimumGap, absolute_minimum_gap + sample.Bank.Length * 3);
|
||||
var node = hasRepeats.NodeSamples[i];
|
||||
|
||||
for (int j = 0; j < node.Count; j++)
|
||||
{
|
||||
var sample = node[j];
|
||||
|
||||
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