Optimize IsMarker checks in TAStudio

This commit is contained in:
Morilli 2024-03-10 18:57:08 +01:00
parent d547ff3d57
commit 87197e0524
2 changed files with 11 additions and 3 deletions

View File

@ -322,7 +322,15 @@ namespace BizHawk.Client.Common
public bool IsMarker(int frame)
{
return this.Any(m => m == frame);
// TODO: could use a BinarySearch here, but CollectionExtensions.BinarySearch currently throws
// an exception on failure, which is probably so expensive it nullifies any performance benefits
foreach (var marker in this)
{
if (marker.Frame > frame) return false;
if (marker.Frame == frame) return true;
}
return false;
}
public TasMovieMarker Get(int frame)

View File

@ -193,7 +193,7 @@ namespace BizHawk.Client.EmuHawk
offsetX = -3;
offsetY = 1;
if (CurrentTasMovie.Markers.IsMarker(index) && Settings.DenoteMarkersWithIcons)
if (Settings.DenoteMarkersWithIcons && CurrentTasMovie.Markers.IsMarker(index))
{
bitmap = icon_marker;
}
@ -235,7 +235,7 @@ namespace BizHawk.Client.EmuHawk
if (columnName == FrameColumnName)
{
if (Emulator.Frame != index && CurrentTasMovie.Markers.IsMarker(index) && Settings.DenoteMarkersWithBGColor)
if (Emulator.Frame != index && Settings.DenoteMarkersWithBGColor && CurrentTasMovie.Markers.IsMarker(index))
{
color = Palette.Marker_FrameCol;
}