mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 04:22:55 +08:00
Do not regenerate breaks unless meaningful change to object start/end times is detected
Tangentially found when profiling https://github.com/ppy/osu/pull/28792. For reproduction, import https://osu.ppy.sh/beatmapsets/972#osu/9007, move any object on the playfield, and observe a half-second freeze when ending the drag.
This commit is contained in:
parent
13c8370823
commit
343090e3b1
@ -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 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
private readonly IBeatmapProcessor? rulesetBeatmapProcessor;
|
||||
|
||||
/// <summary>
|
||||
/// Kept for the purposes of reducing redundant regeneration of automatic breaks.
|
||||
/// </summary>
|
||||
private HashSet<(double, double)> objectDurationCache = new HashSet<(double, double)>();
|
||||
|
||||
public EditorBeatmapProcessor(EditorBeatmap beatmap, Ruleset ruleset)
|
||||
{
|
||||
Beatmap = beatmap;
|
||||
@ -38,6 +44,13 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
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())
|
||||
|
Loading…
Reference in New Issue
Block a user