BK2LogEntryGenerator - further optimize by doing the control ordering once

This commit is contained in:
adelikat 2023-05-25 13:32:58 -05:00
parent f697a828c8
commit 33ed05b20c
1 changed files with 4 additions and 2 deletions

View File

@ -13,12 +13,14 @@ namespace BizHawk.Client.Common
private readonly IController _source; private readonly IController _source;
private readonly Dictionary<string, char> _mnemonics = new(); private readonly Dictionary<string, char> _mnemonics = new();
private readonly List<IReadOnlyList<string>> _controlsOrdered;
public Bk2LogEntryGenerator(string systemId, IController source) public Bk2LogEntryGenerator(string systemId, IController source)
{ {
_systemId = systemId; _systemId = systemId;
_source = source; _source = source;
foreach (var group in _source.Definition.ControlsOrdered.Where(static c => c.Count is not 0)) _controlsOrdered = _source.Definition.ControlsOrdered.Where(static c => c.Count is not 0).ToList();
foreach (var group in _controlsOrdered)
{ {
foreach (var button in group) foreach (var button in group)
{ {
@ -74,7 +76,7 @@ namespace BizHawk.Client.Common
sb.Append('|'); sb.Append('|');
foreach (var group in _source.Definition.ControlsOrdered.Where(static c => c.Count is not 0)) foreach (var group in _controlsOrdered)
{ {
foreach (var button in group) foreach (var button in group)
{ {