Fix some redundant length checks around `foreach`

This commit is contained in:
YoshiRulz 2025-01-31 14:25:55 +10:00
parent 2874ce14c8
commit adcbc8a030
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
4 changed files with 8 additions and 20 deletions

View File

@ -27,14 +27,11 @@ namespace BizHawk.Client.EmuHawk
private void EditCommentsForm_Load(object sender, EventArgs e)
{
if (_movie.Comments.Any())
for (int i = 0; i < _movie.Comments.Count; i++)
{
for (int i = 0; i < _movie.Comments.Count; i++)
{
CommentGrid.Rows.Add();
var c = CommentGrid.Rows[i].Cells[0];
c.Value = _movie.Comments[i];
}
CommentGrid.Rows.Add();
var c = CommentGrid.Rows[i].Cells[0];
c.Value = _movie.Comments[i];
}
if (_readOnly)

View File

@ -182,7 +182,6 @@ namespace BizHawk.Client.EmuHawk
private void RemoveBreakpointButton_Click(object sender, EventArgs e)
{
if (!EditableItems.Any()) return;
var items = EditableItems.ToList();
if (!items.Any()) return;
foreach (var item in items) _breakpoints.Remove(item);
@ -205,7 +204,6 @@ namespace BizHawk.Client.EmuHawk
private void BreakpointView_ItemActivate(object sender, EventArgs e)
{
if (!EditableItems.Any()) return;
var items = EditableItems.ToList();
if (!items.Any()) return;
foreach (var item in items) item.Active = !item.Active;

View File

@ -1390,12 +1390,9 @@ namespace BizHawk.Client.EmuHawk
}
}
if (_extraAxisRows.Any())
foreach (int row in _extraAxisRows)
{
foreach (int row in _extraAxisRows)
{
CurrentTasMovie.SetAxisState(row, _axisEditColumn, value);
}
CurrentTasMovie.SetAxisState(row, _axisEditColumn, value);
}
if (value != prev) // Auto-restore

View File

@ -94,17 +94,13 @@ namespace BizHawk.Emulation.Cores.Arcades.MAME
var DIPSwitchOptions = MameGetString(MAMELuaCommand.GetDIPSwitchOptions(tag, fieldName));
var options = DIPSwitchOptions.Split(new[] { '@' }, StringSplitOptions.RemoveEmptyEntries);
if (options.Length is 0) continue;
foreach (var option in options)
{
var opt = option.Split(new[] { '~' }, StringSplitOptions.RemoveEmptyEntries);
setting.Options.Add(opt[0], opt[1]);
}
if (options.Any())
{
CurrentDriverSettings.Add(setting);
}
CurrentDriverSettings.Add(setting);
}
}
}