From 6d7d36c1d02eede04b78e29acb93d8e50fd86076 Mon Sep 17 00:00:00 2001 From: adelikat Date: Tue, 19 May 2020 19:30:24 -0500 Subject: [PATCH] delete HowMany() extension method and just use .Count() instead, the one value add of null/empty checking was never utilized anyway --- src/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs | 2 +- src/BizHawk.Common/Extensions/NumericStringExtensions.cs | 4 ++-- src/BizHawk.Common/Extensions/StringExtensions.cs | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs b/src/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs index 6b00842ada..a4f755b345 100644 --- a/src/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs +++ b/src/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs @@ -400,7 +400,7 @@ namespace BizHawk.Client.Common continue; } - var numColumns = line.HowMany('\t'); + var numColumns = line.Count(c => c == '\t'); int startIndex; if (numColumns == 5) { diff --git a/src/BizHawk.Common/Extensions/NumericStringExtensions.cs b/src/BizHawk.Common/Extensions/NumericStringExtensions.cs index e25359d2a4..2d156f05f5 100644 --- a/src/BizHawk.Common/Extensions/NumericStringExtensions.cs +++ b/src/BizHawk.Common/Extensions/NumericStringExtensions.cs @@ -27,7 +27,7 @@ namespace BizHawk.Common.StringExtensions /// This method returning for some does not imply that float.TryParse will also return .
/// Also this has nothing to do with fixed- vs. floating-point numbers, a better name would be IsUnsignedDecimal. /// - public static bool IsFixedPoint(this string? str) => !string.IsNullOrWhiteSpace(str) && str.HowMany('.') <= 1 && str.All(IsFixedPoint); + public static bool IsFixedPoint(this string? str) => !string.IsNullOrWhiteSpace(str) && str.Count(c => c == '.') <= 1 && str.All(IsFixedPoint); /// iff is '-', '.', or a digit /// Also this has nothing to do with fixed- vs. floating-point numbers, a better name would be IsSignedDecimal. @@ -80,7 +80,7 @@ namespace BizHawk.Common.StringExtensions /// This method returning for some does not imply that float.TryParse will also return .
/// Also this has nothing to do with fixed- vs. floating-point numbers, a better name would be IsSignedDecimal. /// - public static bool IsFloat(this string? str) => !string.IsNullOrWhiteSpace(str) && str.HowMany('.') <= 1 && str[0].IsFloat() && str.Substring(1).All(IsFixedPoint); + public static bool IsFloat(this string? str) => !string.IsNullOrWhiteSpace(str) && str.Count(c => c == '.') <= 1 && str[0].IsFloat() && str.Substring(1).All(IsFixedPoint); /// /// iff is not , diff --git a/src/BizHawk.Common/Extensions/StringExtensions.cs b/src/BizHawk.Common/Extensions/StringExtensions.cs index 72004a33fd..5ccebffa09 100644 --- a/src/BizHawk.Common/Extensions/StringExtensions.cs +++ b/src/BizHawk.Common/Extensions/StringExtensions.cs @@ -5,9 +5,6 @@ namespace BizHawk.Common.StringExtensions { public static class StringExtensions { - /// how many times appears in , or 0 if is null - public static int HowMany(this string? str, char c) => string.IsNullOrEmpty(str) ? 0 : str.Count(t => t == c); - /// if appears in (case-insensitive) public static bool In(this string str, params string[] options) => options.Any(opt => string.Equals(opt, str, StringComparison.InvariantCultureIgnoreCase)); }