Remove IEnumerable.Any check when iterating the same IEnumerable
This commit is contained in:
parent
f45201ce7a
commit
718e60cbc4
|
@ -51,89 +51,77 @@ namespace BizHawk.Client.Common
|
|||
public void CallSaveStateEvent(string name)
|
||||
{
|
||||
var lfs = _luaFunctions.Where(l => l.Event == "OnSavestateSave").ToList();
|
||||
if (lfs.Any())
|
||||
try
|
||||
{
|
||||
try
|
||||
foreach (var lf in lfs)
|
||||
{
|
||||
foreach (var lf in lfs)
|
||||
{
|
||||
lf.Call(name);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log(
|
||||
"error running function attached by lua function event.onsavestate" +
|
||||
"\nError message: " +
|
||||
e.Message);
|
||||
lf.Call(name);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log(
|
||||
"error running function attached by lua function event.onsavestate" +
|
||||
"\nError message: " +
|
||||
e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void CallLoadStateEvent(string name)
|
||||
{
|
||||
var lfs = _luaFunctions.Where(l => l.Event == "OnSavestateLoad").ToList();
|
||||
if (lfs.Any())
|
||||
try
|
||||
{
|
||||
try
|
||||
foreach (var lf in lfs)
|
||||
{
|
||||
foreach (var lf in lfs)
|
||||
{
|
||||
lf.Call(name);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log(
|
||||
"error running function attached by lua function event.onloadstate" +
|
||||
"\nError message: " +
|
||||
e.Message);
|
||||
lf.Call(name);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log(
|
||||
"error running function attached by lua function event.onloadstate" +
|
||||
"\nError message: " +
|
||||
e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void CallFrameBeforeEvent()
|
||||
{
|
||||
var lfs = _luaFunctions.Where(l => l.Event == "OnFrameStart").ToList();
|
||||
if (lfs.Any())
|
||||
try
|
||||
{
|
||||
try
|
||||
foreach (var lf in lfs)
|
||||
{
|
||||
foreach (var lf in lfs)
|
||||
{
|
||||
lf.Call();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log(
|
||||
"error running function attached by lua function event.onframestart" +
|
||||
"\nError message: " +
|
||||
e.Message);
|
||||
lf.Call();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log(
|
||||
"error running function attached by lua function event.onframestart" +
|
||||
"\nError message: " +
|
||||
e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void CallFrameAfterEvent()
|
||||
{
|
||||
var lfs = _luaFunctions.Where(l => l.Event == "OnFrameEnd").ToList();
|
||||
if (lfs.Any())
|
||||
try
|
||||
{
|
||||
try
|
||||
foreach (var lf in lfs)
|
||||
{
|
||||
foreach (var lf in lfs)
|
||||
{
|
||||
lf.Call();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log(
|
||||
"error running function attached by lua function event.onframeend" +
|
||||
"\nError message: " +
|
||||
e.Message);
|
||||
lf.Call();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log(
|
||||
"error running function attached by lua function event.onframeend" +
|
||||
"\nError message: " +
|
||||
e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private bool N64CoreTypeDynarec()
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace BizHawk.Client.Common
|
|||
public Dictionary<string, string> Map()
|
||||
{
|
||||
var dict = new Dictionary<string, string>();
|
||||
foreach (var group in _source.Definition.ControlsOrdered.Where(c => c.Any()))
|
||||
foreach (var group in _source.Definition.ControlsOrdered)
|
||||
{
|
||||
foreach (var button in group)
|
||||
{
|
||||
|
|
|
@ -319,16 +319,13 @@ namespace BizHawk.Client.Common.MovieConversionExtensions
|
|||
}
|
||||
}
|
||||
|
||||
if (Global.FirmwareManager.RecentlyServed.Any())
|
||||
foreach (var firmware in Global.FirmwareManager.RecentlyServed)
|
||||
{
|
||||
foreach (var firmware in Global.FirmwareManager.RecentlyServed)
|
||||
{
|
||||
var key = firmware.SystemId + "_Firmware_" + firmware.FirmwareId;
|
||||
var key = firmware.SystemId + "_Firmware_" + firmware.FirmwareId;
|
||||
|
||||
if (!movie.HeaderEntries.ContainsKey(key))
|
||||
{
|
||||
movie.HeaderEntries.Add(key, firmware.Hash);
|
||||
}
|
||||
if (!movie.HeaderEntries.ContainsKey(key))
|
||||
{
|
||||
movie.HeaderEntries.Add(key, firmware.Hash);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -471,13 +471,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
(c as AnalogBindControl).Unbind_Click(null, null);
|
||||
}
|
||||
|
||||
if (c.Controls().Any())
|
||||
{
|
||||
foreach (Control child in c.Controls())
|
||||
{
|
||||
ClearWidgetAndChildren(child);
|
||||
}
|
||||
}
|
||||
foreach (var child in c.Controls()) ClearWidgetAndChildren(child);
|
||||
}
|
||||
|
||||
private void ClearBtn_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -52,11 +52,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
public void GetMovie(IMovie m)
|
||||
{
|
||||
_selectedMovie = m;
|
||||
if (!m.Comments.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < m.Comments.Count; i++)
|
||||
{
|
||||
CommentGrid.Rows.Add();
|
||||
|
|
|
@ -443,17 +443,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void RemoveCheatMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var items = SelectedItems.ToList();
|
||||
if (items.Any())
|
||||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
Global.CheatList.Remove(item);
|
||||
}
|
||||
|
||||
CheatListView.SelectedIndices.Clear();
|
||||
UpdateDialog();
|
||||
}
|
||||
Global.CheatList.RemoveRange(SelectedItems);
|
||||
CheatListView.SelectedIndices.Clear();
|
||||
UpdateDialog();
|
||||
}
|
||||
|
||||
private void InsertSeparatorMenuItem_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -196,21 +196,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void RemoveBreakpointButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (EditableItems.Any())
|
||||
{
|
||||
var items = EditableItems.ToList();
|
||||
if (items.Any())
|
||||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
_breakpoints.Remove(item);
|
||||
}
|
||||
|
||||
BreakpointView.ItemCount = _breakpoints.Count;
|
||||
UpdateBreakpointRemoveButton();
|
||||
UpdateStatsLabel();
|
||||
}
|
||||
}
|
||||
var items = EditableItems.ToList();
|
||||
if (items.Count == 0) return;
|
||||
foreach (var item in items) _breakpoints.Remove(item);
|
||||
BreakpointView.ItemCount = _breakpoints.Count;
|
||||
UpdateBreakpointRemoveButton();
|
||||
UpdateStatsLabel();
|
||||
}
|
||||
|
||||
private void UpdateBreakpointRemoveButton()
|
||||
|
@ -231,21 +222,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void BreakpointView_ItemActivate(object sender, EventArgs e)
|
||||
{
|
||||
if (EditableItems.Any())
|
||||
{
|
||||
var items = EditableItems.ToList();
|
||||
if (items.Any())
|
||||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
item.Active ^= true;
|
||||
}
|
||||
|
||||
BreakpointView.ItemCount = _breakpoints.Count;
|
||||
UpdateBreakpointRemoveButton();
|
||||
UpdateStatsLabel();
|
||||
}
|
||||
}
|
||||
var items = EditableItems.ToList();
|
||||
if (items.Count == 0) return;
|
||||
foreach (var item in items) item.Active ^= true;
|
||||
BreakpointView.ItemCount = _breakpoints.Count;
|
||||
UpdateBreakpointRemoveButton();
|
||||
UpdateStatsLabel();
|
||||
}
|
||||
|
||||
private void BreakpointView_KeyDown(object sender, KeyEventArgs e)
|
||||
|
|
|
@ -1452,12 +1452,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
if (_extraFloatRows.Any())
|
||||
foreach (var row in _extraFloatRows)
|
||||
{
|
||||
foreach (int row in _extraFloatRows)
|
||||
{
|
||||
CurrentTasMovie.SetFloatState(row, _floatEditColumn, value);
|
||||
}
|
||||
CurrentTasMovie.SetFloatState(row, _floatEditColumn, value);
|
||||
}
|
||||
|
||||
if (value != prev) // Auto-restore
|
||||
|
|
Loading…
Reference in New Issue