Cleanup TasStateManager.Invalidate
had this written down for after #1591 merge
This commit is contained in:
parent
023da20cb9
commit
dabbaae075
|
@ -172,29 +172,15 @@ namespace BizHawk.Client.Common
|
||||||
return _states.ContainsKey(frame);
|
return _states.ContainsKey(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <returns>true iff any frames were invalidated</returns>
|
||||||
public bool Invalidate(int frame)
|
public bool Invalidate(int frame)
|
||||||
{
|
{
|
||||||
bool anyInvalidated = false;
|
if (!Any()) return false;
|
||||||
|
if (frame == 0) frame = 1; // Never invalidate frame 0
|
||||||
if (Any())
|
var statesToRemove = _states.Where(s => s.Key >= frame).ToList();
|
||||||
{
|
foreach (var state in statesToRemove) Remove(state.Key);
|
||||||
if (frame == 0) // Never invalidate frame 0
|
|
||||||
{
|
|
||||||
frame = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<KeyValuePair<int, byte[]>> statesToRemove = _states.Where(s => s.Key >= frame).ToList();
|
|
||||||
anyInvalidated = statesToRemove.Any();
|
|
||||||
|
|
||||||
foreach (var state in statesToRemove)
|
|
||||||
{
|
|
||||||
Remove(state.Key);
|
|
||||||
}
|
|
||||||
|
|
||||||
InvalidateCallback?.Invoke(frame);
|
InvalidateCallback?.Invoke(frame);
|
||||||
}
|
return statesToRemove.Count != 0;
|
||||||
|
|
||||||
return anyInvalidated;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Remove(int frame)
|
public bool Remove(int frame)
|
||||||
|
|
Loading…
Reference in New Issue