From 2feece847fb1a02f82d1f7ab13a84d1f24caf79a Mon Sep 17 00:00:00 2001 From: nattthebear Date: Mon, 10 Aug 2020 10:59:23 -0400 Subject: [PATCH] I don't understand why we're clearing the rewind buffer, but if we want to do that, just do it, and don't deallocate + reallocate many megs of ram on every loadstate (#2282) --- src/BizHawk.Client.Common/rewind/IRewinder.cs | 2 ++ src/BizHawk.Client.Common/rewind/Zwinder.cs | 5 +++++ src/BizHawk.Client.EmuHawk/MainForm.cs | 9 ++------- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/BizHawk.Client.Common/rewind/IRewinder.cs b/src/BizHawk.Client.Common/rewind/IRewinder.cs index aa7e0b9fe9..6e88dd6d0e 100644 --- a/src/BizHawk.Client.Common/rewind/IRewinder.cs +++ b/src/BizHawk.Client.Common/rewind/IRewinder.cs @@ -19,5 +19,7 @@ namespace BizHawk.Client.Common void Suspend(); void Resume(); + + void Clear(); } } diff --git a/src/BizHawk.Client.Common/rewind/Zwinder.cs b/src/BizHawk.Client.Common/rewind/Zwinder.cs index 94c4a2bef6..93d10a4f1d 100644 --- a/src/BizHawk.Client.Common/rewind/Zwinder.cs +++ b/src/BizHawk.Client.Common/rewind/Zwinder.cs @@ -85,5 +85,10 @@ namespace BizHawk.Client.Common { // this possess no resources to dispose of, but other IRewinder impls might } + + public void Clear() + { + _buffer.InvalidateEnd(0); + } } } diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index 222a8a8d27..5699c791e4 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -887,17 +887,12 @@ namespace BizHawk.Client.EmuHawk public IRewinder Rewinder { get; private set; } public void CreateRewinder() - { - RecreateRewinder(); - AddOnScreenMessage(Rewinder?.Active == true ? "Rewind started" : "Rewind disabled"); - } - - void RecreateRewinder() { Rewinder?.Dispose(); Rewinder = Emulator.HasSavestates() && Config.Rewind.Enabled ? new Zwinder(Emulator.AsStatable(), Config.Rewind) : null; + AddOnScreenMessage(Rewinder?.Active == true ? "Rewind started" : "Rewind disabled"); } private FirmwareManager FirmwareManager => GlobalWin.FirmwareManager; @@ -3992,7 +3987,7 @@ namespace BizHawk.Client.EmuHawk //so purge rewind history when loading a state while doing a movie if (!IsRewindSlave && MovieSession.Movie.IsActive()) { - RecreateRewinder(); + Rewinder?.Clear(); } if (!suppressOSD)