TasMovie - TasStateManager - pre-allocate the SortedDictionary size based on state size and memory usage capacity. Fixes the problem of performance grinding to a halt as the movie frame count increases

This commit is contained in:
adelikat 2014-08-24 22:50:21 +00:00
parent 63b533f15c
commit 3aec45448c
1 changed files with 15 additions and 0 deletions

View File

@ -21,6 +21,21 @@ namespace BizHawk.Client.Common
{
_movie = movie;
Settings = new ManagerSettings();
var cap = Settings.Cap;
int limit = 0;
if (Global.Emulator != null)
{
var stateSize = Global.Emulator.SaveStateBinary().Length;
if (stateSize > 0)
{
limit = cap / stateSize;
}
}
States = new SortedList<int, byte[]>(limit);
}
public ManagerSettings Settings { get; set; }