[StringExtensions] - Minor optimization for ContainsLetter().

This commit is contained in:
Ivandro Ismael 2016-08-31 22:10:24 +01:00
parent 294b3f646e
commit ea42ec4184
No known key found for this signature in database
GPG Key ID: A8832757DEFB7EDC

View File

@ -153,13 +153,14 @@ namespace Nikse.SubtitleEdit.Core
public static bool ContainsLetter(this string s)
{
if (string.IsNullOrWhiteSpace(s))
return false;
foreach (var c in s)
if (s != null)
{
if (char.IsLetter(c))
return true;
foreach (var index in StringInfo.ParseCombiningCharacters(s))
{
var uc = CharUnicodeInfo.GetUnicodeCategory(s, index);
if (uc == UnicodeCategory.LowercaseLetter || uc == UnicodeCategory.UppercaseLetter || uc == UnicodeCategory.TitlecaseLetter || uc == UnicodeCategory.ModifierLetter || uc == UnicodeCategory.OtherLetter)
return true;
}
}
return false;
}