diff --git a/BizHawk.Client.Common/RecentFiles.cs b/BizHawk.Client.Common/RecentFiles.cs index 1ecedee4a1..798d09be0c 100644 --- a/BizHawk.Client.Common/RecentFiles.cs +++ b/BizHawk.Client.Common/RecentFiles.cs @@ -89,17 +89,9 @@ namespace BizHawk.Client.Common { if (!Frozen) { - var removed = false; - foreach (var recent in recentlist) - { - if (string.Compare(newFile, recent, StringComparison.CurrentCultureIgnoreCase) == 0) - { - recentlist.Remove(newFile); // intentionally keeps iterating after this to remove duplicate instances, though those should never exist in the first place - removed = true; - } - } - - return removed; + var oldCount = recentlist.Count; + recentlist.RemoveAll(recent => string.Equals(newFile, recent, StringComparison.CurrentCultureIgnoreCase)); // removes duplicate instances, though those should never exist in the first place + return recentlist.Count != oldCount; } return false; diff --git a/BizHawk.Client.Common/config/PathEntry.cs b/BizHawk.Client.Common/config/PathEntry.cs index aa345690bd..9ba993245f 100644 --- a/BizHawk.Client.Common/config/PathEntry.cs +++ b/BizHawk.Client.Common/config/PathEntry.cs @@ -104,19 +104,7 @@ namespace BizHawk.Client.Common List entriesToRemove = new List(); // Remove entries that no longer exist in defaults - foreach (PathEntry pathEntry in Paths) - { - var path = DefaultValues.FirstOrDefault(p => p.System == pathEntry.System && p.Type == pathEntry.Type); - if (path == null) - { - entriesToRemove.Add(pathEntry); - } - } - - foreach (PathEntry entry in entriesToRemove) - { - Paths.Remove(entry); - } + Paths.RemoveAll(path => DefaultValues.All(p => p.System != path.System || p.Type != path.Type)); // Add missing displaynames foreach (var path in Paths.Where(p => p.SystemDisplayName == null)) diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Forms.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Forms.cs index 2c1e5cc08c..3ef76cc3a3 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Forms.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Forms.cs @@ -149,10 +149,7 @@ namespace BizHawk.Client.EmuHawk { if (control.Handle == ptr) { - foreach (var luaEvent in form.ControlEvents.Where(x => x.Control == ptr)) - { - form.ControlEvents.Remove(luaEvent); - } + form.ControlEvents.RemoveAll(x => x.Control == ptr); } } } diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamPoke.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamPoke.cs index 253ff2aabd..823c002866 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamPoke.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamPoke.cs @@ -35,7 +35,7 @@ namespace BizHawk.Client.EmuHawk private void RamPoke_Load(object sender, EventArgs e) { - _watchList = _watchList.Where(x => !x.IsSeparator).ToList(); // Weed out separators just in case + _watchList.RemoveAll(x => x.IsSeparator); // just in case if (_watchList.Count == 0) { diff --git a/BizHawk.Emulation.Cores/Computers/AmstradCPC/SoundProviderMixer.cs b/BizHawk.Emulation.Cores/Computers/AmstradCPC/SoundProviderMixer.cs index 9b5c926bc6..fd44c5dab7 100644 --- a/BizHawk.Emulation.Cores/Computers/AmstradCPC/SoundProviderMixer.cs +++ b/BizHawk.Emulation.Cores/Computers/AmstradCPC/SoundProviderMixer.cs @@ -90,13 +90,7 @@ namespace BizHawk.Emulation.Cores.Computers.AmstradCPC public void DisableSource(ISoundProvider source) { - var sp = SoundProviders.Where(a => a.SoundProvider == source); - if (sp.Count() == 1) - SoundProviders.Remove(sp.First()); - else if (sp.Count() > 1) - foreach (var s in sp) - SoundProviders.Remove(s); - + SoundProviders.RemoveAll(a => a.SoundProvider == source); EqualizeVolumes(); } diff --git a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/SoundProviderMixer.cs b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/SoundProviderMixer.cs index 95cfb1a335..f6e6b7cf6f 100644 --- a/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/SoundProviderMixer.cs +++ b/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/SoundProviderMixer.cs @@ -90,13 +90,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum public void DisableSource(ISoundProvider source) { - var sp = SoundProviders.Where(a => a.SoundProvider == source); - if (sp.Count() == 1) - SoundProviders.Remove(sp.First()); - else if (sp.Count() > 1) - foreach (var s in sp) - SoundProviders.Remove(s); - + SoundProviders.RemoveAll(a => a.SoundProvider == source); EqualizeVolumes(); }