From 730cc645fb134df2a00994d64405dbadb967ca38 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 28 Oct 2020 16:33:52 +0900 Subject: [PATCH] Avoid reconstructing ruleset for each frame bundle --- osu.Game/Screens/Play/Spectator.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/Spectator.cs b/osu.Game/Screens/Play/Spectator.cs index f788dcd8c7..2de6c16c45 100644 --- a/osu.Game/Screens/Play/Spectator.cs +++ b/osu.Game/Screens/Play/Spectator.cs @@ -38,6 +38,8 @@ namespace osu.Game.Screens.Play [Resolved] private Bindable ruleset { get; set; } + private Ruleset rulesetInstance; + [Resolved] private Bindable> mods { get; set; } @@ -141,12 +143,10 @@ namespace osu.Game.Screens.Play if (replay == null) return; - var rulesetInstance = ruleset.Value.CreateInstance(); - foreach (var frame in data.Frames) { IConvertibleReplayFrame convertibleFrame = rulesetInstance.CreateConvertibleReplayFrame(); - convertibleFrame.FromLegacy(frame, beatmap.Value.Beatmap, null); + convertibleFrame.FromLegacy(frame, beatmap.Value.Beatmap); var convertedFrame = (ReplayFrame)convertibleFrame; convertedFrame.Time = frame.Time; @@ -206,6 +206,8 @@ namespace osu.Game.Screens.Play }; ruleset.Value = resolvedRuleset.RulesetInfo; + rulesetInstance = resolvedRuleset; + beatmap.Value = beatmaps.GetWorkingBeatmap(resolvedBeatmap); this.Push(new SpectatorPlayerLoader(new Score