Merge pull request #1935 from ivandrofly/se

[StringExtensions] - Minor optimization for ContainsLetter().
This commit is contained in:
Nikolaj Olsson 2016-09-04 21:37:50 +02:00 committed by GitHub
commit e5691b7a15

View File

@ -153,14 +153,15 @@ 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))
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;
}