From c7dfc3d9b019224602bb9c54dd32bfbed37bcbd4 Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 6 Oct 2017 21:03:23 -0700 Subject: [PATCH] Cleanup union / count usages remove unnecessary stuff --- PKHeX.Core/Legality/Core.cs | 2 +- PKHeX.Core/Legality/Encounters/VerifyCurrentMoves.cs | 2 +- PKHeX.Core/Legality/Encounters/VerifyRelearnMoves.cs | 4 ++-- PKHeX.WinForms/Subforms/PKM Editors/BatchEditor.cs | 2 +- PKHeX.WinForms/Subforms/SAV_MysteryGiftDB.cs | 3 ++- Tests/PKHeX.Tests/PKM/PIDIVTests.cs | 3 +-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/PKHeX.Core/Legality/Core.cs b/PKHeX.Core/Legality/Core.cs index 8785288d9..b186a0d7d 100644 --- a/PKHeX.Core/Legality/Core.cs +++ b/PKHeX.Core/Legality/Core.cs @@ -1639,7 +1639,7 @@ private static IEnumerable GetValidMoves(PKM pkm, GameVersion Version, IRea if (vs[gen].Any()) r.AddRange(GetValidMoves(pkm, Version, vs[gen], gen, minLvLG1: minLvLG1, minLvLG2: minLvLG2, LVL: LVL, Relearn: false, Tutor: Tutor, Machine: Machine, MoveReminder: MoveReminder, RemoveTransferHM: RemoveTransferHM)); - return r.Distinct().ToArray(); + return r.Distinct(); } private static IEnumerable GetValidMoves(PKM pkm, GameVersion Version, DexLevel[] vs, int Generation, int minLvLG1 = 1, int minLvLG2 = 1, bool LVL = false, bool Relearn = false, bool Tutor = false, bool Machine = false, bool MoveReminder = true, bool RemoveTransferHM = true) { diff --git a/PKHeX.Core/Legality/Encounters/VerifyCurrentMoves.cs b/PKHeX.Core/Legality/Encounters/VerifyCurrentMoves.cs index 7ac74e8d1..f7df4126d 100644 --- a/PKHeX.Core/Legality/Encounters/VerifyCurrentMoves.cs +++ b/PKHeX.Core/Legality/Encounters/VerifyCurrentMoves.cs @@ -745,7 +745,7 @@ private static int GetRequiredBaseMoveCount(int[] Moves, EggInfoSource infoset) int inheritCt = inherited.Count; // Get required amount of base moves - int unique = infoset.Base.Concat(inherited).Distinct().Count(); + int unique = infoset.Base.Union(inherited).Count(); int reqBase = inheritCt == 4 || baseCt + inheritCt > 4 ? 4 - inheritCt : baseCt; if (Moves.Count(m => m != 0) < Math.Min(4, infoset.Base.Count)) reqBase = Math.Min(4, unique); diff --git a/PKHeX.Core/Legality/Encounters/VerifyRelearnMoves.cs b/PKHeX.Core/Legality/Encounters/VerifyRelearnMoves.cs index e122ff53b..8c0d186c6 100644 --- a/PKHeX.Core/Legality/Encounters/VerifyRelearnMoves.cs +++ b/PKHeX.Core/Legality/Encounters/VerifyRelearnMoves.cs @@ -172,9 +172,9 @@ private static int GetRequiredBaseMoves(int[] RelearnMoves, IReadOnlyList b int inheritCt = inherited.Count; // Get required amount of base moves - int unique = baseMoves.Concat(inherited).Distinct().Count(); + int unique = baseMoves.Union(inherited).Count(); int reqBase = inheritCt == 4 || baseCt + inheritCt > 4 ? 4 - inheritCt : baseCt; - if (RelearnMoves.Where(m => m != 0).Count() < Math.Min(4, baseMoves.Count)) + if (RelearnMoves.Count(m => m != 0) < Math.Min(4, baseMoves.Count)) reqBase = Math.Min(4, unique); return reqBase; } diff --git a/PKHeX.WinForms/Subforms/PKM Editors/BatchEditor.cs b/PKHeX.WinForms/Subforms/PKM Editors/BatchEditor.cs index 27f9fe91c..912d3225b 100644 --- a/PKHeX.WinForms/Subforms/PKM Editors/BatchEditor.cs +++ b/PKHeX.WinForms/Subforms/PKM Editors/BatchEditor.cs @@ -40,7 +40,7 @@ private static string[][] GetPropArray() p[i] = ReflectFrameworkUtil.GetPropertiesCanWritePublicDeclared(types[i]).Concat(CustomProperties).OrderBy(a => a).ToArray(); // Properties for any PKM - var any = ReflectFrameworkUtil.GetPropertiesCanWritePublic(typeof(PK1)).Concat(p.SelectMany(a => a)).Distinct().OrderBy(a => a).ToArray(); + var any = ReflectFrameworkUtil.GetPropertiesCanWritePublic(typeof(PK1)).Union(p.SelectMany(a => a)).OrderBy(a => a).ToArray(); // Properties shared by all PKM var all = p.Aggregate(new HashSet(p.First()), (h, e) => { h.IntersectWith(e); return h; }).OrderBy(a => a).ToArray(); diff --git a/PKHeX.WinForms/Subforms/SAV_MysteryGiftDB.cs b/PKHeX.WinForms/Subforms/SAV_MysteryGiftDB.cs index 0fac007b6..a4b629fb5 100644 --- a/PKHeX.WinForms/Subforms/SAV_MysteryGiftDB.cs +++ b/PKHeX.WinForms/Subforms/SAV_MysteryGiftDB.cs @@ -207,7 +207,8 @@ private void LoadDatabase() RawDB.AddRange(Legal.MGDB_G6); RawDB.AddRange(Legal.MGDB_G7); - RawDB = new List(RawDB.Where(mg => !mg.IsItem && mg.IsPokémon && mg.Species > 0).Distinct().Concat(Legal.MGDB_G3).OrderBy(mg => mg.Species)); + RawDB = new List(RawDB.Where(mg => !mg.IsItem && mg.IsPokémon && mg.Species > 0).Distinct() + .Concat(Legal.MGDB_G3).OrderBy(mg => mg.Species)); foreach (var mg in RawDB) mg.GiftUsed = false; BeginInvoke(new MethodInvoker(delegate diff --git a/Tests/PKHeX.Tests/PKM/PIDIVTests.cs b/Tests/PKHeX.Tests/PKM/PIDIVTests.cs index 6f1aea2b1..51db6a480 100644 --- a/Tests/PKHeX.Tests/PKM/PIDIVTests.cs +++ b/Tests/PKHeX.Tests/PKM/PIDIVTests.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Linq; using PKHeX.Core;