Optimize TAStudio column drawing by caching PlayerNumber for each column name
TAStudio previously called `PlayerNumber(...)` for each visible cell with the column's name, only to determine whether its player number is odd or even. Because that function uses regex and is potentially called extremely often, this had a noticable impact on fps. I've decided to just cache the odd/even playernumber result in a dictionary for faster access, which while not being my preferred way of handling this at least results in a decent speedup.
This commit is contained in:
parent
afb92870e4
commit
396e876320
|
@ -62,6 +62,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
private int? _seekStartFrame;
|
||||
private bool _unpauseAfterSeeking;
|
||||
|
||||
private readonly Dictionary<string, bool> _alternateRowColor = new();
|
||||
|
||||
private ControllerDefinition ControllerType => MovieSession.MovieController.Definition;
|
||||
|
||||
public bool WasRecording { get; set; }
|
||||
|
@ -247,8 +249,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
color = Palette.AnalogEdit_Col;
|
||||
}
|
||||
|
||||
int player = Emulator.ControllerDefinition.PlayerNumber(columnName);
|
||||
if (player != 0 && player % 2 == 0)
|
||||
if (!_alternateRowColor.ContainsKey(columnName))
|
||||
{
|
||||
int playerNumber = ControllerDefinition.PlayerNumber(columnName);
|
||||
_alternateRowColor[columnName] = playerNumber != 0 && playerNumber % 2 == 0;
|
||||
}
|
||||
|
||||
if (_alternateRowColor[columnName])
|
||||
{
|
||||
color = Color.FromArgb(0x0D, 0x00, 0x00, 0x00);
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ namespace BizHawk.Emulation.Common
|
|||
return this;
|
||||
}
|
||||
|
||||
public int PlayerNumber(string buttonName)
|
||||
public static int PlayerNumber(string buttonName)
|
||||
{
|
||||
var match = PlayerRegex.Match(buttonName);
|
||||
return match.Success
|
||||
|
|
Loading…
Reference in New Issue