From b7514fdeadfc49aa592c0bc56697990c1d81aa8e Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Thu, 14 Jan 2021 18:18:52 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=8E=20Improve=20performancee=20on=20st?= =?UTF-8?q?ring.IsLower()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Item for #12 --- X10D/src/StringExtensions.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/X10D/src/StringExtensions.cs b/X10D/src/StringExtensions.cs index fbf506f..8a88a32 100644 --- a/X10D/src/StringExtensions.cs +++ b/X10D/src/StringExtensions.cs @@ -179,14 +179,27 @@ /// /// Determines if all alpha characters in this string are considered lowercase. /// - /// The input string. + /// The input string. /// /// Returns if all alpha characters are lowercase, /// otherwise. /// - public static bool IsLower(this string str) + public static bool IsLower(this string value) { - return str.Where(char.IsLetter).All(char.IsLower); + for (var index = 0; index < value.Length; index++) + { + if (!char.IsLetter(value[index])) + { + continue; + } + + if (!char.IsLower(value[index])) + { + return false; + } + } + + return true; } ///