From 8362d078a4f5bd6947b2a74616753f801dc30812 Mon Sep 17 00:00:00 2001 From: adelikat Date: Wed, 2 Jul 2014 23:50:09 +0000 Subject: [PATCH] Ram Search - IEnumerable instead of IList, Any() instead of Count > 0, makes a few things a bit faster in large search lists --- .../tools/Watch/RamSearch.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs index ea0f0f2d22..0e7365fd8c 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs @@ -497,9 +497,9 @@ namespace BizHawk.Client.EmuHawk _forcePreviewClear = true; } - private IList SelectedIndices + private IEnumerable SelectedIndices { - get { return WatchListView.SelectedIndices.Cast().ToList(); } + get { return WatchListView.SelectedIndices.Cast(); } } private IEnumerable SelectedItems @@ -779,11 +779,12 @@ namespace BizHawk.Client.EmuHawk private void RemoveAddresses() { - if (SelectedIndices.Count > 0) + var indices = SelectedIndices.ToList(); + if (indices.Any()) { - SetRemovedMessage(SelectedIndices.Count); + SetRemovedMessage(indices.Count); - var addresses = SelectedIndices.Select(index => _searches[index].Address ?? 0).ToList(); + var addresses = indices.Select(index => _searches[index].Address ?? 0).ToList(); _searches.RemoveRange(addresses); WatchListView.ItemCount = _searches.Count; @@ -851,7 +852,7 @@ namespace BizHawk.Client.EmuHawk private void PokeAddress() { - if (SelectedIndices.Count > 0) + if (SelectedIndices.Any()) { var poke = new RamPoke(); var watches = SelectedIndices.Select(t => _searches[t]).ToList(); @@ -1397,7 +1398,7 @@ namespace BizHawk.Client.EmuHawk ContextMenuSeparator2.Visible = ViewInHexEditorContextMenuItem.Visible = - SelectedIndices.Count > 0; + SelectedIndices.Any(); UnfreezeAllContextMenuItem.Visible = Global.CheatList.ActiveCount > 0; @@ -1664,7 +1665,7 @@ namespace BizHawk.Client.EmuHawk } else if (e.KeyCode == Keys.C && e.Control && !e.Alt && !e.Shift) // Copy { - if (SelectedIndices.Count > 0) + if (SelectedIndices.Any()) { var sb = new StringBuilder(); foreach (var index in SelectedIndices) @@ -1721,7 +1722,7 @@ namespace BizHawk.Client.EmuHawk private void WatchListView_MouseDoubleClick(object sender, MouseEventArgs e) { - if (SelectedIndices.Count > 0) + if (SelectedIndices.Any()) { AddToRamWatch(); }