Introduce constants for type inside loop

This commit is contained in:
Ivandro Ismael 2015-08-10 09:17:15 +01:00
parent ea0a310ee7
commit 5027a528af

View File

@ -684,31 +684,34 @@ namespace Nikse.SubtitleEdit.Logic
splitPos = -1;
}
const string expectedChars1 = ".!?, ";
const string expectedChars2 = " .!?";
const string expectedChars3 = ".!?";
if (splitPos < 0)
{
for (int j = 0; j < 25; j++)
{
if (mid + j + 1 < s.Length && mid + j > 0)
{
if (@".!?, ".Contains(s[mid + j]) && !IsPartOfNumber(s, mid + j) && s.Length > mid + j + 2 && CanBreak(s, mid + j, language))
if (expectedChars1.Contains(s[mid + j]) && !IsPartOfNumber(s, mid + j) && s.Length > mid + j + 2 && CanBreak(s, mid + j, language))
{
splitPos = mid + j;
if (@" .!?".Contains(s[mid + j + 1]))
if (expectedChars2.Contains(s[mid + j + 1]))
{
splitPos++;
if (@" .!?".Contains(s[mid + j + 2]))
if (expectedChars2.Contains(s[mid + j + 2]))
splitPos++;
}
break;
}
if (@".!?, ".Contains(s[mid - j]) && !IsPartOfNumber(s, mid - j) && s.Length > mid + j + 2 && CanBreak(s, mid - j, language))
if (expectedChars1.Contains(s[mid - j]) && !IsPartOfNumber(s, mid - j) && s.Length > mid + j + 2 && CanBreak(s, mid - j, language))
{
splitPos = mid - j;
if (@".!?".Contains(s[splitPos]))
if (expectedChars3.Contains(s[splitPos]))
splitPos--;
if (@".!?".Contains(s[splitPos]))
if (expectedChars3.Contains(s[splitPos]))
splitPos--;
if (@".!?".Contains(s[splitPos]))
if (expectedChars3.Contains(s[splitPos]))
splitPos--;
break;
}