From 2f9e05972f767757cf56357ae1347f94886d51f2 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 9 Apr 2022 12:25:19 -0700 Subject: [PATCH] slick switch expression Might be a target for future refactoring if Format(int) is changed in the future... --- PKHeX.Core/PKM/Searching/SearchUtil.cs | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/PKHeX.Core/PKM/Searching/SearchUtil.cs b/PKHeX.Core/PKM/Searching/SearchUtil.cs index 459ab7fc8..20c9801c0 100644 --- a/PKHeX.Core/PKM/Searching/SearchUtil.cs +++ b/PKHeX.Core/PKM/Searching/SearchUtil.cs @@ -8,24 +8,17 @@ namespace PKHeX.Core.Searching /// public static class SearchUtil { - public static bool SatisfiesFilterFormat(PKM pk, int format, SearchComparison formatOperand) + // Future: Might need to clamp down further for generations that cannot exist in the current format. + public static bool SatisfiesFilterFormat(PKM pk, int format, SearchComparison formatOperand) => formatOperand switch { - switch (formatOperand) - { - case SearchComparison.GreaterThanEquals when pk.Format < format: - case SearchComparison.Equals when pk.Format != format: - case SearchComparison.LessThanEquals when pk.Format > format: - return false; - } + SearchComparison.GreaterThanEquals when pk.Format < format => false, + SearchComparison.Equals when pk.Format != format => false, + SearchComparison.LessThanEquals when pk.Format > format => false, - // Might need to clamp down further for generations that cannot exist in the current format. - return format switch - { - <= 2 => pk.Format <= 2, // 1-2 - <= 6 => pk.Format >= 3, // 3-6 - _ => true, - }; - } + _ when format <= 2 => pk.Format <= 2, // 1-2 + _ when format <= 6 => pk.Format >= 3, // 3-6 + _ => true, + }; public static bool SatisfiesFilterGeneration(PKM pk, int generation) => generation switch {