diff --git a/osu.Game/Screens/Edit/EditorBeatmapProcessor.cs b/osu.Game/Screens/Edit/EditorBeatmapProcessor.cs index 377e978c4a5a..9b6d956a4ce1 100644 --- a/osu.Game/Screens/Edit/EditorBeatmapProcessor.cs +++ b/osu.Game/Screens/Edit/EditorBeatmapProcessor.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Collections.Generic; using System.Linq; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Timing; @@ -18,6 +19,11 @@ public class EditorBeatmapProcessor : IBeatmapProcessor private readonly IBeatmapProcessor? rulesetBeatmapProcessor; + /// + /// Kept for the purposes of reducing redundant regeneration of automatic breaks. + /// + private HashSet<(double, double)> objectDurationCache = new HashSet<(double, double)>(); + public EditorBeatmapProcessor(EditorBeatmap beatmap, Ruleset ruleset) { Beatmap = beatmap; @@ -38,6 +44,13 @@ public void PostProcess() private void autoGenerateBreaks() { + var objectDuration = Beatmap.HitObjects.Select(ho => (ho.StartTime, ho.GetEndTime())).ToHashSet(); + + if (objectDuration.SetEquals(objectDurationCache)) + return; + + objectDurationCache = objectDuration; + Beatmap.Breaks.RemoveAll(b => b is not ManualBreakPeriod); foreach (var manualBreak in Beatmap.Breaks.ToList())