mirror of
https://github.com/ppy/osu.git
synced 2025-01-18 11:52: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,
|
// 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 = [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 = [BANK_NORMAL, BANK_SOFT, BANK_DRUM];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The name of the sample to load.
|
/// The name of the sample to load.
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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>
|
||||||
{
|
{
|
||||||
|
@ -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()
|
||||||
|
@ -155,9 +155,11 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
if (hitObject.GetEndTime() < editorClock.CurrentTime - timeline.VisibleRange / 2)
|
if (hitObject.GetEndTime() < editorClock.CurrentTime - timeline.VisibleRange / 2)
|
||||||
break;
|
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);
|
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);
|
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))
|
var node = hasRepeats.NodeSamples[i];
|
||||||
minimumGap = Math.Max(minimumGap, absolute_minimum_gap + sample.Bank.Length * 3);
|
|
||||||
|
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